From d2bec03d934ae1f60fc6cbc736eb2689fa9e9d0b Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 30 May 2026 21:39:53 +1000 Subject: [PATCH] Fix for offloading of check_for_migrations (#12041) * Do not raise exception in offload_task * Revert "Do not raise exception in offload_task" This reverts commit 9f9a9a5240a201362fe40f79caf5df8d4f13edac. * Improve offloading of check_for_migrations * update playwright Ref: https://github.com/microsoft/playwright/issues/40998 --- src/backend/InvenTree/InvenTree/apps.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/InvenTree/InvenTree/apps.py b/src/backend/InvenTree/InvenTree/apps.py index 50d5b6ae5d..53c15f01ef 100644 --- a/src/backend/InvenTree/InvenTree/apps.py +++ b/src/backend/InvenTree/InvenTree/apps.py @@ -64,9 +64,20 @@ class InvenTreeConfig(AppConfig): self.collect_tasks() self.start_background_tasks() - if not InvenTree.ready.isInTestMode(): # pragma: no cover + if ( + not InvenTree.ready.isInTestMode() + and not InvenTree.ready.isInWorkerThread() + ): # pragma: no cover # Let the background worker check for migrations - InvenTree.tasks.offload_task(InvenTree.tasks.check_for_migrations) + # Don't offload task if we are already *in* the background worker, otherwise we might end up in a deadlock situation + + try: + InvenTree.tasks.offload_task(InvenTree.tasks.check_for_migrations) + except Exception as exc: + logger.exception( + 'Failed to offload check_for_migrations task: %s', exc + ) + # Update exchange rates InvenTree.tasks.offload_task( InvenTree.tasks.update_exchange_rates, force_async=True