simple-module-background-tasks 0.0.43__tar.gz → 0.0.45__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/PKG-INFO +6 -6
  2. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/README.md +1 -1
  3. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/__init__.py +9 -9
  4. simple_module_background_tasks-0.0.45/background_tasks/celery_app.py +13 -0
  5. simple_module_background_tasks-0.0.45/background_tasks/config_guards.py +17 -0
  6. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/contracts/outbox.py +1 -1
  7. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/contracts/schemas.py +1 -1
  8. simple_module_background_tasks-0.0.45/background_tasks/core/__init__.py +7 -0
  9. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/core}/_lifecycle.py +17 -17
  10. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/core}/config_guards.py +1 -1
  11. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/core}/invalidation.py +20 -1
  12. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/core}/services.py +2 -2
  13. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/core}/settings.py +11 -9
  14. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/core}/settings_celery.py +4 -4
  15. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/core}/settings_env_checks.py +19 -6
  16. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/core}/settings_logs.py +1 -1
  17. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/core}/tracking.py +6 -2
  18. simple_module_background_tasks-0.0.45/background_tasks/executions/__init__.py +5 -0
  19. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/executions}/filters.py +1 -1
  20. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/executions}/retry_service.py +10 -10
  21. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/executions}/service.py +27 -36
  22. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/executions}/tenant_context.py +6 -2
  23. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/locales/de.json +6 -2
  24. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/locales/en.json +6 -2
  25. simple_module_background_tasks-0.0.45/background_tasks/logs/__init__.py +4 -0
  26. simple_module_background_tasks-0.0.43/background_tasks/log_service.py → simple_module_background_tasks-0.0.45/background_tasks/logs/service.py +1 -1
  27. simple_module_background_tasks-0.0.43/background_tasks/log_sink.py → simple_module_background_tasks-0.0.45/background_tasks/logs/sink.py +5 -5
  28. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/models.py +27 -3
  29. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/module.py +13 -13
  30. simple_module_background_tasks-0.0.45/background_tasks/outbox/__init__.py +5 -0
  31. simple_module_background_tasks-0.0.43/background_tasks/outbox_claim.py → simple_module_background_tasks-0.0.45/background_tasks/outbox/claim.py +2 -2
  32. simple_module_background_tasks-0.0.43/background_tasks/outbox_dispatch.py → simple_module_background_tasks-0.0.45/background_tasks/outbox/dispatch.py +4 -4
  33. simple_module_background_tasks-0.0.43/background_tasks/outbox_service.py → simple_module_background_tasks-0.0.45/background_tasks/outbox/service.py +3 -3
  34. simple_module_background_tasks-0.0.43/background_tasks/outbox_support.py → simple_module_background_tasks-0.0.45/background_tasks/outbox/support.py +2 -2
  35. simple_module_background_tasks-0.0.43/background_tasks/outbox_sweep.py → simple_module_background_tasks-0.0.45/background_tasks/outbox/sweep.py +3 -3
  36. simple_module_background_tasks-0.0.43/background_tasks/outbox_transport.py → simple_module_background_tasks-0.0.45/background_tasks/outbox/transport.py +6 -6
  37. simple_module_background_tasks-0.0.43/background_tasks/outbox_worker.py → simple_module_background_tasks-0.0.45/background_tasks/outbox/worker.py +8 -8
  38. simple_module_background_tasks-0.0.45/background_tasks/outbox_transport.py +15 -0
  39. simple_module_background_tasks-0.0.45/background_tasks/outbox_worker.py +15 -0
  40. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/pages/Detail.tsx +11 -11
  41. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/pages/Index.tsx +23 -13
  42. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/pages/Logs.tsx +6 -6
  43. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/pages/Outbox.tsx +5 -5
  44. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/pages/Workers.tsx +36 -14
  45. simple_module_background_tasks-0.0.45/background_tasks/runner.py +13 -0
  46. simple_module_background_tasks-0.0.45/background_tasks/settings.py +15 -0
  47. simple_module_background_tasks-0.0.45/background_tasks/sync_db.py +15 -0
  48. simple_module_background_tasks-0.0.45/background_tasks/task_routing.py +17 -0
  49. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/tasks.py +8 -8
  50. simple_module_background_tasks-0.0.45/background_tasks/tenant_context.py +17 -0
  51. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/DetailFacts.tsx +1 -1
  52. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/ExecutionRow.tsx +2 -2
  53. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/ExecutionsTable.tsx +1 -1
  54. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/LogLevelSelect.tsx +1 -1
  55. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/LogTable.tsx +2 -2
  56. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/LogsPanel.tsx +1 -1
  57. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/OutboxTable.tsx +2 -2
  58. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/PayloadCards.tsx +1 -1
  59. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/ProgressCard.tsx +1 -1
  60. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/RetryAllDialog.tsx +1 -1
  61. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/RetryConfirmDialog.tsx +1 -1
  62. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/RoutesTable.tsx +1 -1
  63. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/StatusPill.tsx +1 -1
  64. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/StatusStrip.tsx +1 -1
  65. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/TaskFilters.tsx +1 -1
  66. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/TasksEmpty.tsx +46 -31
  67. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/WorkerCard.tsx +29 -1
  68. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/WorkerHealthBanner.tsx +3 -3
  69. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui/utils}/constants.ts +3 -1
  70. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui/utils}/logs.ts +1 -1
  71. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui/utils}/outbox.ts +1 -1
  72. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui/utils}/retry.ts +1 -1
  73. simple_module_background_tasks-0.0.45/background_tasks/web/__init__.py +1 -0
  74. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/web}/deps.py +4 -4
  75. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/web}/endpoints/api_admin.py +10 -10
  76. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/web}/endpoints/api_status.py +8 -3
  77. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/web}/endpoints/logs_api.py +9 -4
  78. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/web}/endpoints/logs_views.py +3 -3
  79. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/web}/endpoints/outbox_api.py +4 -4
  80. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/web}/endpoints/outbox_views.py +3 -3
  81. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/web}/endpoints/views.py +29 -20
  82. simple_module_background_tasks-0.0.45/background_tasks/worker/__init__.py +6 -0
  83. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/worker}/_signal_support.py +5 -5
  84. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/worker}/celery_app.py +16 -8
  85. simple_module_background_tasks-0.0.43/background_tasks/workers_state.py → simple_module_background_tasks-0.0.45/background_tasks/worker/fleet_state.py +1 -1
  86. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/worker}/runner.py +7 -7
  87. simple_module_background_tasks-0.0.43/background_tasks/worker_settings.py → simple_module_background_tasks-0.0.45/background_tasks/worker/settings.py +3 -3
  88. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/worker}/signals.py +20 -16
  89. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/worker}/task_heartbeat.py +5 -5
  90. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/worker}/task_resource.py +2 -2
  91. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/worker}/task_routing.py +2 -2
  92. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/worker}/tenant_celery.py +1 -1
  93. simple_module_background_tasks-0.0.45/background_tasks/worker_settings.py +15 -0
  94. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/package.json +1 -1
  95. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/pyproject.toml +5 -5
  96. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/tests/conftest.py +17 -2
  97. simple_module_background_tasks-0.0.43/tests/test_bg_redis_health.py → simple_module_background_tasks-0.0.45/tests/core/health/test_background_tasks_redis_health.py +1 -1
  98. simple_module_background_tasks-0.0.43/tests/test_bg_invalidation.py → simple_module_background_tasks-0.0.45/tests/core/invalidation/test_background_tasks_invalidation.py +4 -4
  99. simple_module_background_tasks-0.0.43/tests/test_bg_invalidation_degraded.py → simple_module_background_tasks-0.0.45/tests/core/invalidation/test_background_tasks_invalidation_degraded.py +5 -5
  100. simple_module_background_tasks-0.0.43/tests/test_bg_invalidation_redis.py → simple_module_background_tasks-0.0.45/tests/core/invalidation/test_background_tasks_invalidation_redis.py +22 -3
  101. simple_module_background_tasks-0.0.45/tests/core/invalidation/test_background_tasks_invalidation_warmup.py +190 -0
  102. simple_module_background_tasks-0.0.43/tests/test_beat_schedule.py → simple_module_background_tasks-0.0.45/tests/core/settings/test_background_tasks_beat_schedule.py +3 -3
  103. simple_module_background_tasks-0.0.43/tests/test_bg_config_guards.py → simple_module_background_tasks-0.0.45/tests/core/settings/test_background_tasks_config_guards.py +5 -5
  104. simple_module_background_tasks-0.0.43/tests/test_bg_db_timeouts.py → simple_module_background_tasks-0.0.45/tests/core/settings/test_background_tasks_db_timeouts.py +4 -3
  105. simple_module_background_tasks-0.0.43/tests/test_bg_redis_url.py → simple_module_background_tasks-0.0.45/tests/core/settings/test_background_tasks_redis_url.py +75 -2
  106. {simple_module_background_tasks-0.0.43/tests → simple_module_background_tasks-0.0.45/tests/core/settings}/test_background_tasks_settings.py +5 -5
  107. simple_module_background_tasks-0.0.43/tests/test_bg_settings_env.py → simple_module_background_tasks-0.0.45/tests/core/settings/test_background_tasks_settings_env.py +2 -2
  108. simple_module_background_tasks-0.0.43/tests/test_sync_db.py → simple_module_background_tasks-0.0.45/tests/core/sync_db/test_background_tasks_sync_db.py +1 -1
  109. simple_module_background_tasks-0.0.43/tests/test_sync_db_fork.py → simple_module_background_tasks-0.0.45/tests/core/sync_db/test_background_tasks_sync_db_fork.py +1 -1
  110. simple_module_background_tasks-0.0.43/tests/test_retry_failed_bulk.py → simple_module_background_tasks-0.0.45/tests/executions/retry/test_background_tasks_retry_failed_bulk.py +1 -1
  111. simple_module_background_tasks-0.0.43/tests/test_retry_failed_guards.py → simple_module_background_tasks-0.0.45/tests/executions/retry/test_background_tasks_retry_failed_guards.py +2 -2
  112. simple_module_background_tasks-0.0.43/tests/test_retry_sweep_ordering.py → simple_module_background_tasks-0.0.45/tests/executions/retry/test_background_tasks_retry_sweep_ordering.py +3 -3
  113. {simple_module_background_tasks-0.0.43/tests → simple_module_background_tasks-0.0.45/tests/executions/service}/test_background_tasks_after_commit.py +5 -4
  114. {simple_module_background_tasks-0.0.43/tests → simple_module_background_tasks-0.0.45/tests/executions/service}/test_background_tasks_eager_bindings.py +5 -5
  115. simple_module_background_tasks-0.0.43/tests/test_bg_index_has_executions.py → simple_module_background_tasks-0.0.45/tests/executions/service/test_background_tasks_index_has_executions.py +1 -1
  116. simple_module_background_tasks-0.0.43/tests/test_bg_list_item_payload.py → simple_module_background_tasks-0.0.45/tests/executions/service/test_background_tasks_list_item_payload.py +1 -1
  117. simple_module_background_tasks-0.0.45/tests/executions/service/test_background_tasks_newest_first_status.py +53 -0
  118. simple_module_background_tasks-0.0.45/tests/executions/service/test_background_tasks_order_index.py +90 -0
  119. {simple_module_background_tasks-0.0.43/tests → simple_module_background_tasks-0.0.45/tests/executions/service}/test_background_tasks_publish_validation.py +3 -3
  120. simple_module_background_tasks-0.0.45/tests/executions/service/test_background_tasks_read_projection.py +107 -0
  121. {simple_module_background_tasks-0.0.43/tests → simple_module_background_tasks-0.0.45/tests/executions/service}/test_background_tasks_retention_retries.py +3 -2
  122. {simple_module_background_tasks-0.0.43/tests → simple_module_background_tasks-0.0.45/tests/executions/service}/test_background_tasks_savepoint_publish.py +2 -1
  123. simple_module_background_tasks-0.0.43/tests/test_bg_service.py → simple_module_background_tasks-0.0.45/tests/executions/service/test_background_tasks_service.py +2 -2
  124. {simple_module_background_tasks-0.0.43/tests → simple_module_background_tasks-0.0.45/tests/executions/service}/test_background_tasks_tz_columns.py +2 -2
  125. simple_module_background_tasks-0.0.43/tests/test_bg_log_purge.py → simple_module_background_tasks-0.0.45/tests/logs/purge/test_background_tasks_log_purge.py +4 -2
  126. simple_module_background_tasks-0.0.43/tests/test_log_context.py → simple_module_background_tasks-0.0.45/tests/logs/sink/test_background_tasks_log_context.py +2 -2
  127. simple_module_background_tasks-0.0.43/tests/test_bg_log_sink.py → simple_module_background_tasks-0.0.45/tests/logs/sink/test_background_tasks_log_sink.py +4 -3
  128. simple_module_background_tasks-0.0.43/tests/test_bg_log_sink_loop.py → simple_module_background_tasks-0.0.45/tests/logs/sink/test_background_tasks_log_sink_loop.py +3 -2
  129. simple_module_background_tasks-0.0.43/tests/test_bg_log_sink_nul.py → simple_module_background_tasks-0.0.45/tests/logs/sink/test_background_tasks_log_sink_nul.py +1 -1
  130. simple_module_background_tasks-0.0.43/tests/test_outbox_admin.py → simple_module_background_tasks-0.0.45/tests/outbox/admin/test_background_tasks_outbox_admin.py +3 -3
  131. simple_module_background_tasks-0.0.43/tests/test_outbox_tenancy.py → simple_module_background_tasks-0.0.45/tests/outbox/admin/test_background_tasks_outbox_tenancy.py +1 -1
  132. {simple_module_background_tasks-0.0.43/tests → simple_module_background_tasks-0.0.45/tests/outbox/delivery}/test_background_tasks_delivery_context.py +2 -2
  133. simple_module_background_tasks-0.0.43/tests/test_bg_inprocess_sweep.py → simple_module_background_tasks-0.0.45/tests/outbox/delivery/test_background_tasks_inprocess_sweep.py +5 -5
  134. simple_module_background_tasks-0.0.43/tests/test_outbox_concurrency.py → simple_module_background_tasks-0.0.45/tests/outbox/delivery/test_background_tasks_outbox_concurrency.py +3 -3
  135. simple_module_background_tasks-0.0.43/tests/test_outbox_delivery.py → simple_module_background_tasks-0.0.45/tests/outbox/delivery/test_background_tasks_outbox_delivery.py +4 -4
  136. simple_module_background_tasks-0.0.43/tests/test_bg_outbox_eager_platform.py → simple_module_background_tasks-0.0.45/tests/outbox/delivery/test_background_tasks_outbox_eager_platform.py +11 -8
  137. simple_module_background_tasks-0.0.43/tests/test_bg_outbox_eager_serialization.py → simple_module_background_tasks-0.0.45/tests/outbox/delivery/test_background_tasks_outbox_eager_serialization.py +1 -1
  138. simple_module_background_tasks-0.0.43/tests/test_bg_outbox_fence_guard.py → simple_module_background_tasks-0.0.45/tests/outbox/delivery/test_background_tasks_outbox_fence_guard.py +3 -3
  139. simple_module_background_tasks-0.0.43/tests/test_bg_outbox_guard_savepoint.py → simple_module_background_tasks-0.0.45/tests/outbox/delivery/test_background_tasks_outbox_guard_savepoint.py +4 -4
  140. simple_module_background_tasks-0.0.43/tests/test_bg_outbox_publish_scope.py → simple_module_background_tasks-0.0.45/tests/outbox/delivery/test_background_tasks_outbox_publish_scope.py +3 -3
  141. simple_module_background_tasks-0.0.43/tests/test_bg_outbox_retry_policy.py → simple_module_background_tasks-0.0.45/tests/outbox/delivery/test_background_tasks_outbox_retry_policy.py +5 -5
  142. simple_module_background_tasks-0.0.43/tests/test_bg_outbox_swallowed_cancel.py → simple_module_background_tasks-0.0.45/tests/outbox/delivery/test_background_tasks_outbox_swallowed_cancel.py +3 -3
  143. simple_module_background_tasks-0.0.43/tests/test_bg_outbox_worker_chain.py → simple_module_background_tasks-0.0.45/tests/outbox/delivery/test_background_tasks_outbox_worker_chain.py +7 -5
  144. simple_module_background_tasks-0.0.43/tests/test_outbox_worker_task.py → simple_module_background_tasks-0.0.45/tests/outbox/delivery/test_background_tasks_outbox_worker_task.py +5 -4
  145. simple_module_background_tasks-0.0.43/tests/test_bg_outbox_loop_interrupt.py → simple_module_background_tasks-0.0.45/tests/outbox/loop/test_background_tasks_outbox_loop_interrupt.py +1 -1
  146. simple_module_background_tasks-0.0.43/tests/test_bg_outbox_thread_loops.py → simple_module_background_tasks-0.0.45/tests/outbox/loop/test_background_tasks_outbox_thread_loops.py +3 -2
  147. simple_module_background_tasks-0.0.43/tests/test_admin_api.py → simple_module_background_tasks-0.0.45/tests/web/api/test_background_tasks_admin_api.py +1 -1
  148. simple_module_background_tasks-0.0.43/tests/test_detail_props.py → simple_module_background_tasks-0.0.45/tests/web/api/test_background_tasks_detail_props.py +1 -1
  149. simple_module_background_tasks-0.0.43/tests/test_index_filters.py → simple_module_background_tasks-0.0.45/tests/web/api/test_background_tasks_index_filters.py +1 -1
  150. simple_module_background_tasks-0.0.43/tests/test_bg_page_clamp.py → simple_module_background_tasks-0.0.45/tests/web/api/test_background_tasks_page_clamp.py +1 -1
  151. simple_module_background_tasks-0.0.43/tests/test_bg_task_status_api.py → simple_module_background_tasks-0.0.45/tests/web/api/test_background_tasks_task_status_api.py +1 -1
  152. simple_module_background_tasks-0.0.43/tests/test_bg_users_ordering.py → simple_module_background_tasks-0.0.45/tests/web/api/test_background_tasks_users_ordering.py +1 -1
  153. simple_module_background_tasks-0.0.43/tests/test_bg_index_worker_presence.py → simple_module_background_tasks-0.0.45/tests/worker/inspector/test_background_tasks_index_worker_presence.py +46 -13
  154. simple_module_background_tasks-0.0.43/tests/test_worker_inspector.py → simple_module_background_tasks-0.0.45/tests/worker/inspector/test_background_tasks_worker_inspector.py +7 -7
  155. simple_module_background_tasks-0.0.43/tests/test_workers_endpoints.py → simple_module_background_tasks-0.0.45/tests/worker/inspector/test_background_tasks_workers_endpoints.py +8 -6
  156. simple_module_background_tasks-0.0.43/tests/test_workers_uptime.py → simple_module_background_tasks-0.0.45/tests/worker/inspector/test_background_tasks_workers_uptime.py +12 -10
  157. simple_module_background_tasks-0.0.43/tests/test_bg_routes_override_api.py → simple_module_background_tasks-0.0.45/tests/worker/runner/test_background_tasks_routes_override_api.py +3 -3
  158. simple_module_background_tasks-0.0.43/tests/test_bg_runner_settings.py → simple_module_background_tasks-0.0.45/tests/worker/runner/test_background_tasks_runner_settings.py +8 -8
  159. simple_module_background_tasks-0.0.43/tests/test_bg_task_routing.py → simple_module_background_tasks-0.0.45/tests/worker/runner/test_background_tasks_task_routing.py +5 -5
  160. simple_module_background_tasks-0.0.43/tests/test_bg_worker_settings.py → simple_module_background_tasks-0.0.45/tests/worker/runner/test_background_tasks_worker_settings.py +2 -2
  161. {simple_module_background_tasks-0.0.43/tests → simple_module_background_tasks-0.0.45/tests/worker/signals}/test_background_tasks_argument_json.py +4 -4
  162. {simple_module_background_tasks-0.0.43/tests → simple_module_background_tasks-0.0.45/tests/worker/signals}/test_background_tasks_execution_bindings.py +4 -4
  163. {simple_module_background_tasks-0.0.43/tests → simple_module_background_tasks-0.0.45/tests/worker/signals}/test_background_tasks_heartbeat.py +4 -3
  164. simple_module_background_tasks-0.0.43/tests/test_bg_quiet_sweep_unrecorded.py → simple_module_background_tasks-0.0.45/tests/worker/signals/test_background_tasks_quiet_sweep_unrecorded.py +5 -5
  165. {simple_module_background_tasks-0.0.43/tests → simple_module_background_tasks-0.0.45/tests/worker/signals}/test_background_tasks_resource_status.py +1 -1
  166. {simple_module_background_tasks-0.0.43/tests → simple_module_background_tasks-0.0.45/tests/worker/signals}/test_background_tasks_resource_transport.py +6 -6
  167. {simple_module_background_tasks-0.0.43/tests → simple_module_background_tasks-0.0.45/tests/worker/signals}/test_background_tasks_result_json.py +5 -4
  168. simple_module_background_tasks-0.0.43/tests/test_signal_tenant_stamp.py → simple_module_background_tasks-0.0.45/tests/worker/signals/test_background_tasks_signal_tenant_stamp.py +3 -3
  169. simple_module_background_tasks-0.0.43/tests/test_signals.py → simple_module_background_tasks-0.0.45/tests/worker/signals/test_background_tasks_signals.py +10 -6
  170. simple_module_background_tasks-0.0.43/tests/test_sweep_stuck.py → simple_module_background_tasks-0.0.45/tests/worker/signals/test_background_tasks_sweep_stuck.py +2 -2
  171. simple_module_background_tasks-0.0.43/tests/test_bg_task_progress.py → simple_module_background_tasks-0.0.45/tests/worker/signals/test_background_tasks_task_progress.py +6 -5
  172. simple_module_background_tasks-0.0.43/tests/test_bg_task_progress_audit.py → simple_module_background_tasks-0.0.45/tests/worker/signals/test_background_tasks_task_progress_audit.py +4 -3
  173. {simple_module_background_tasks-0.0.43/tests → simple_module_background_tasks-0.0.45/tests/worker/signals}/test_background_tasks_tracking_modes.py +11 -11
  174. simple_module_background_tasks-0.0.43/tests/test_bg_worker_audit.py → simple_module_background_tasks-0.0.45/tests/worker/signals/test_background_tasks_worker_audit.py +4 -4
  175. simple_module_background_tasks-0.0.43/tests/test_bg_worker_audit_bookkeeping.py → simple_module_background_tasks-0.0.45/tests/worker/signals/test_background_tasks_worker_audit_bookkeeping.py +3 -3
  176. {simple_module_background_tasks-0.0.43/tests → simple_module_background_tasks-0.0.45/tests/worker/tenancy}/test_background_tasks_custom_bases.py +3 -3
  177. simple_module_background_tasks-0.0.43/tests/test_execution_tenancy.py → simple_module_background_tasks-0.0.45/tests/worker/tenancy/test_background_tasks_execution_tenancy.py +5 -5
  178. simple_module_background_tasks-0.0.43/tests/test_tenant_context.py → simple_module_background_tasks-0.0.45/tests/worker/tenancy/test_background_tasks_tenant_context.py +32 -1
  179. {simple_module_background_tasks-0.0.43/tests → simple_module_background_tasks-0.0.45/tests/worker/tenancy}/test_background_tasks_worker_tenancy.py +1 -1
  180. simple_module_background_tasks-0.0.43/tests/test_worker_tenancy.py → simple_module_background_tasks-0.0.45/tests/worker/tenancy/test_background_tasks_worker_tenancy_context.py +2 -2
  181. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/tests-js/background_tasks_DetailPage.test.tsx +1 -1
  182. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/tests-js/background_tasks_IndexPage.test.tsx +20 -1
  183. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/tests-js/background_tasks_LogsTab.test.tsx +1 -1
  184. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/tests-js/background_tasks_OutboxPage.test.tsx +1 -1
  185. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/tests-js/background_tasks_WorkerHealthBanner.test.tsx +1 -1
  186. simple_module_background_tasks-0.0.45/tests-js/background_tasks_WorkersPage.test.tsx +89 -0
  187. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/tests-js/outbox.test.ts +1 -1
  188. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/tests-js/retry.test.ts +1 -1
  189. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/tests-js/task-formatters.test.ts +1 -1
  190. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/.gitignore +0 -0
  191. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/LICENSE +0 -0
  192. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/contracts/__init__.py +0 -0
  193. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/contracts/events.py +0 -0
  194. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/contracts/logs.py +0 -0
  195. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/core}/constants.py +0 -0
  196. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/core}/db_settings.py +0 -0
  197. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/core}/health.py +0 -0
  198. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/core}/sync_db.py +0 -0
  199. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/executions}/after_commit.py +0 -0
  200. /simple_module_background_tasks-0.0.43/background_tasks/log_purge.py → /simple_module_background_tasks-0.0.45/background_tasks/logs/purge.py +0 -0
  201. /simple_module_background_tasks-0.0.43/background_tasks/outbox_clock.py → /simple_module_background_tasks-0.0.45/background_tasks/outbox/clock.py +0 -0
  202. /simple_module_background_tasks-0.0.43/background_tasks/outbox_guard.py → /simple_module_background_tasks-0.0.45/background_tasks/outbox/guard.py +0 -0
  203. /simple_module_background_tasks-0.0.43/background_tasks/outbox_loop.py → /simple_module_background_tasks-0.0.45/background_tasks/outbox/loop.py +0 -0
  204. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/pages/api.generated.ts +0 -0
  205. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/pages/api.ts +0 -0
  206. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/background_tasks/py.typed +0 -0
  207. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/TracebackCard.tsx +0 -0
  208. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui}/components/WorkerEmptyStates.tsx +0 -0
  209. {simple_module_background_tasks-0.0.43/background_tasks/pages → simple_module_background_tasks-0.0.45/background_tasks/ui/utils}/worker-health.ts +0 -0
  210. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/web}/endpoints/__init__.py +0 -0
  211. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/worker}/_signal_bus.py +0 -0
  212. /simple_module_background_tasks-0.0.43/background_tasks/worker_inspector.py → /simple_module_background_tasks-0.0.45/background_tasks/worker/inspector.py +0 -0
  213. {simple_module_background_tasks-0.0.43/background_tasks → simple_module_background_tasks-0.0.45/background_tasks/worker}/log_context.py +0 -0
  214. /simple_module_background_tasks-0.0.43/tests/test_bg_startup_log_masking.py → /simple_module_background_tasks-0.0.45/tests/core/settings/test_background_tasks_startup_log_masking.py +0 -0
  215. /simple_module_background_tasks-0.0.43/tests/test_bg_log_api.py → /simple_module_background_tasks-0.0.45/tests/web/api/test_background_tasks_log_api.py +0 -0
  216. /simple_module_background_tasks-0.0.43/tests/test_bg_pagination_bounds.py → /simple_module_background_tasks-0.0.45/tests/web/api/test_background_tasks_pagination_bounds.py +0 -0
  217. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/tests-js/stub-fetch.ts +0 -0
  218. {simple_module_background_tasks-0.0.43 → simple_module_background_tasks-0.0.45}/tsconfig.json +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: simple_module_background_tasks
3
- Version: 0.0.43
3
+ Version: 0.0.45
4
4
  Summary: Celery + Redis task queue with admin UI for monitoring and retrying failed/stuck tasks
5
5
  Project-URL: Homepage, https://github.com/antosubash/simple_module_python
6
6
  Project-URL: Repository, https://github.com/antosubash/simple_module_python
@@ -23,10 +23,10 @@ Classifier: Typing :: Typed
23
23
  Requires-Python: >=3.12
24
24
  Requires-Dist: celery[redis]<6,>=5.4
25
25
  Requires-Dist: redis<9,>=5
26
- Requires-Dist: simple-module-core==0.0.43
27
- Requires-Dist: simple-module-db==0.0.43
28
- Requires-Dist: simple-module-hosting==0.0.43
29
- Requires-Dist: simple-module-settings==0.0.43
26
+ Requires-Dist: simple-module-core==0.0.45
27
+ Requires-Dist: simple-module-db==0.0.45
28
+ Requires-Dist: simple-module-hosting==0.0.45
29
+ Requires-Dist: simple-module-settings==0.0.45
30
30
  Description-Content-Type: text/markdown
31
31
 
32
32
  # simple_module_background_tasks
@@ -45,7 +45,7 @@ Requires a Redis broker. The broker / result-backend URLs are module settings (`
45
45
 
46
46
  - Zero-config task discovery — any installed module that ships a `tasks.py` has its tasks autodiscovered (`celery.autodiscover_tasks` imports `<package>.tasks` for every installed module). No per-module registration hook.
47
47
  - Admin UI at `/admin/background-tasks` — list recent runs, retry failed, inspect tracebacks (gated by the `background_tasks.view` permission).
48
- - `build_celery(settings)` factory in `background_tasks.celery_app`, plus `bind_task_context` / `get_log_context` / `install_log_filter` exported from the package root (import name `background_tasks`, distribution name `simple_module_background_tasks`).
48
+ - `build_celery(settings)` factory in `background_tasks.worker.celery_app`, plus `bind_task_context` / `get_log_context` / `install_log_filter` exported from the package root (import name `background_tasks`, distribution name `simple_module_background_tasks`).
49
49
  - `enqueue_after_commit(db, task, *args, **kwargs)` — publish a task only once the session's transaction commits, never on rollback.
50
50
  - `heartbeat()` — called from a long task body, keeps the stuck sweep from flagging it; `@shared_task(stuck_after=seconds)` sets a per-task stuck threshold. See the module docs for both.
51
51
 
@@ -14,7 +14,7 @@ Requires a Redis broker. The broker / result-backend URLs are module settings (`
14
14
 
15
15
  - Zero-config task discovery — any installed module that ships a `tasks.py` has its tasks autodiscovered (`celery.autodiscover_tasks` imports `<package>.tasks` for every installed module). No per-module registration hook.
16
16
  - Admin UI at `/admin/background-tasks` — list recent runs, retry failed, inspect tracebacks (gated by the `background_tasks.view` permission).
17
- - `build_celery(settings)` factory in `background_tasks.celery_app`, plus `bind_task_context` / `get_log_context` / `install_log_filter` exported from the package root (import name `background_tasks`, distribution name `simple_module_background_tasks`).
17
+ - `build_celery(settings)` factory in `background_tasks.worker.celery_app`, plus `bind_task_context` / `get_log_context` / `install_log_filter` exported from the package root (import name `background_tasks`, distribution name `simple_module_background_tasks`).
18
18
  - `enqueue_after_commit(db, task, *args, **kwargs)` — publish a task only once the session's transaction commits, never on rollback.
19
19
  - `heartbeat()` — called from a long task body, keeps the stuck sweep from flagging it; `@shared_task(stuck_after=seconds)` sets a per-task stuck threshold. See the module docs for both.
20
20
 
@@ -2,19 +2,19 @@
2
2
 
3
3
  from typing import TYPE_CHECKING, Any
4
4
 
5
- from background_tasks.after_commit import enqueue_after_commit
6
- from background_tasks.constants import SM_TRACKING_HEADER
7
- from background_tasks.log_context import (
5
+ from background_tasks.core.constants import SM_TRACKING_HEADER
6
+ from background_tasks.core.tracking import TrackingMode
7
+ from background_tasks.executions.after_commit import enqueue_after_commit
8
+ from background_tasks.worker.log_context import (
8
9
  bind_task_context,
9
10
  get_log_context,
10
11
  install_log_filter,
11
12
  )
12
- from background_tasks.task_resource import with_task_resource
13
- from background_tasks.tracking import TrackingMode
13
+ from background_tasks.worker.task_resource import with_task_resource
14
14
 
15
15
  if TYPE_CHECKING:
16
- from background_tasks.task_heartbeat import heartbeat
17
- from background_tasks.worker_settings import settings_for
16
+ from background_tasks.worker.settings import settings_for
17
+ from background_tasks.worker.task_heartbeat import heartbeat
18
18
 
19
19
  _LAZY_HEARTBEAT = "heartbeat"
20
20
  _LAZY_SETTINGS = "settings_for"
@@ -22,11 +22,11 @@ _LAZY_SETTINGS = "settings_for"
22
22
 
23
23
  def __getattr__(name: str) -> Any:
24
24
  if name == _LAZY_HEARTBEAT:
25
- from background_tasks.task_heartbeat import heartbeat
25
+ from background_tasks.worker.task_heartbeat import heartbeat
26
26
 
27
27
  return heartbeat
28
28
  if name == _LAZY_SETTINGS:
29
- from background_tasks.worker_settings import settings_for
29
+ from background_tasks.worker.settings import settings_for
30
30
 
31
31
  return settings_for
32
32
  raise AttributeError(name)
@@ -0,0 +1,13 @@
1
+ """Moved to :mod:`background_tasks.worker.celery_app`; this alias goes in 0.0.46 (module layout)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib
6
+ import sys
7
+
8
+ from simple_module_core.deprecation import deprecated_module
9
+
10
+ deprecated_module(
11
+ "background_tasks.celery_app", remove_in="0.0.46", use="background_tasks.worker.celery_app"
12
+ )
13
+ sys.modules[__name__] = importlib.import_module("background_tasks.worker.celery_app")
@@ -0,0 +1,17 @@
1
+ """Moved to :mod:`background_tasks.core.config_guards`;
2
+ this alias goes in 0.0.46 (module layout).
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ import importlib
8
+ import sys
9
+
10
+ from simple_module_core.deprecation import deprecated_module
11
+
12
+ deprecated_module(
13
+ "background_tasks.config_guards",
14
+ remove_in="0.0.46",
15
+ use="background_tasks.core.config_guards",
16
+ )
17
+ sys.modules[__name__] = importlib.import_module("background_tasks.core.config_guards")
@@ -9,7 +9,7 @@ from typing import Any
9
9
  from pydantic import ConfigDict
10
10
  from sqlmodel import SQLModel
11
11
 
12
- from background_tasks.constants import OutboxStatus
12
+ from background_tasks.core.constants import OutboxStatus
13
13
 
14
14
 
15
15
  class OutboxItem(SQLModel):
@@ -9,7 +9,7 @@ from typing import Any
9
9
  from pydantic import ConfigDict, field_validator
10
10
  from sqlmodel import SQLModel
11
11
 
12
- from background_tasks.constants import TaskStatus
12
+ from background_tasks.core.constants import TaskStatus
13
13
 
14
14
 
15
15
  class TaskExecutionListItem(SQLModel):
@@ -0,0 +1,7 @@
1
+ """What every background_tasks feature builds on.
2
+
3
+ Constants, the module settings and their Celery, log and env-check parts,
4
+ worker engine settings, the app.state container, config guards, health,
5
+ lifecycle wiring, the Redis invalidation transport, the sync DB session factory
6
+ and tracking policy.
7
+ """
@@ -22,12 +22,12 @@ async def startup(app: FastAPI, module_name: str) -> None:
22
22
 
23
23
  from simple_module_hosting.log_sinks import redact
24
24
 
25
- from background_tasks.celery_app import build_celery
26
- from background_tasks.db_settings import worker_database_options
27
- from background_tasks.log_sink import install_log_sink
28
- from background_tasks.signals import bind_event_bus
29
- from background_tasks.sync_db import configure_database, set_database_url
30
- from background_tasks.tenant_context import set_default_tenant
25
+ from background_tasks.core.db_settings import worker_database_options
26
+ from background_tasks.core.sync_db import configure_database, set_database_url
27
+ from background_tasks.executions.tenant_context import set_default_tenant
28
+ from background_tasks.logs.sink import install_log_sink
29
+ from background_tasks.worker.celery_app import build_celery
30
+ from background_tasks.worker.signals import bind_event_bus
31
31
 
32
32
  services = app.state.background_tasks
33
33
  # Pin the sync engine to the same URL the host's async settings
@@ -62,7 +62,7 @@ async def startup(app: FastAPI, module_name: str) -> None:
62
62
  # settings changes rather than pinning the boot-time instance.
63
63
  from simple_module_core.health import HealthCheck
64
64
 
65
- from background_tasks.health import CHECK_REDIS, build_redis_check
65
+ from background_tasks.core.health import CHECK_REDIS, build_redis_check
66
66
 
67
67
  app.state.sm.health_registry.add(
68
68
  HealthCheck(
@@ -87,10 +87,10 @@ async def startup(app: FastAPI, module_name: str) -> None:
87
87
 
88
88
  def install_durable_transport(app: FastAPI) -> None:
89
89
  """Make ``bus.publish_durable`` write to this module's outbox (GH #459)."""
90
- from background_tasks.constants import OutboxMode
91
- from background_tasks.outbox_sweep import start_sweep
92
- from background_tasks.outbox_transport import OutboxTransport
93
- from background_tasks.outbox_worker import use_bus
90
+ from background_tasks.core.constants import OutboxMode
91
+ from background_tasks.outbox.sweep import start_sweep
92
+ from background_tasks.outbox.transport import OutboxTransport
93
+ from background_tasks.outbox.worker import use_bus
94
94
 
95
95
  bus = app.state.sm.event_bus
96
96
  services = app.state.background_tasks
@@ -122,7 +122,7 @@ async def start_invalidation_transport(app: FastAPI) -> None:
122
122
  documented cross-process limit as ``bind_event_bus`` above: a task that
123
123
  invalidates a cache should do it through an API call or accept the TTL.
124
124
  """
125
- from background_tasks.invalidation import RedisInvalidationTransport
125
+ from background_tasks.core.invalidation import RedisInvalidationTransport
126
126
 
127
127
  services = app.state.background_tasks
128
128
  s = services.settings
@@ -146,11 +146,11 @@ async def start_invalidation_transport(app: FastAPI) -> None:
146
146
 
147
147
 
148
148
  async def shutdown(app: FastAPI) -> None:
149
- from background_tasks.log_sink import uninstall_log_sink
150
- from background_tasks.outbox_sweep import stop_sweep
151
- from background_tasks.outbox_worker import reset_worker_state
152
- from background_tasks.signals import unbind_event_bus
153
- from background_tasks.sync_db import dispose_sync_engine
149
+ from background_tasks.core.sync_db import dispose_sync_engine
150
+ from background_tasks.logs.sink import uninstall_log_sink
151
+ from background_tasks.outbox.sweep import stop_sweep
152
+ from background_tasks.outbox.worker import reset_worker_state
153
+ from background_tasks.worker.signals import unbind_event_bus
154
154
 
155
155
  await stop_sweep(app.state.background_tasks)
156
156
  bus = getattr(app.state.sm, "event_bus", None)
@@ -29,7 +29,7 @@ import re
29
29
  from dataclasses import dataclass
30
30
  from typing import Any
31
31
 
32
- from background_tasks.constants import ENV_PREFIX
32
+ from background_tasks.core.constants import ENV_PREFIX
33
33
 
34
34
  logger = logging.getLogger(__name__)
35
35
 
@@ -83,7 +83,9 @@ answering would hang that request indefinitely rather than degrade the fan-out.
83
83
  One second is far more than a local round trip needs and far less than a user
84
84
  waits. Exceeding it raises, which the bus logs and swallows: the local eviction
85
85
  has already happened, so the cost of the timeout is the same staleness window
86
- that existed before this transport.
86
+ that existed before this transport. The listener opens the connection a publish
87
+ uses ahead of time (``_warm_publish_connection``), so the budget normally covers
88
+ a round trip on an open socket, not a connect.
87
89
  """
88
90
 
89
91
 
@@ -174,6 +176,7 @@ class RedisInvalidationTransport:
174
176
  pubsub = self._client.pubsub()
175
177
  async with asyncio.timeout(SUBSCRIBE_TIMEOUT_SECONDS):
176
178
  await pubsub.subscribe(self._channel)
179
+ await self._warm_publish_connection()
177
180
  if self._warned:
178
181
  logger.info("Invalidation listener reconnected to %r", self._channel)
179
182
  self._warned = False
@@ -198,6 +201,22 @@ class RedisInvalidationTransport:
198
201
  with contextlib.suppress(Exception):
199
202
  await pubsub.aclose()
200
203
 
204
+ async def _warm_publish_connection(self) -> None:
205
+ """Open the command connection the next publish will use, off the request path.
206
+
207
+ The client opens it lazily, so without this the first publish after boot,
208
+ or after Redis came back, paid the TCP connect inside its 1 s budget and
209
+ lost the message under load (GH #880). Runs after every successful
210
+ SUBSCRIBE because an outage drops both connections. A failure here leaves
211
+ the listener up: the subscription is what keeps this worker receiving, and
212
+ a cold publish still connects on its own.
213
+ """
214
+ try:
215
+ async with asyncio.timeout(SUBSCRIBE_TIMEOUT_SECONDS):
216
+ await self._client.ping()
217
+ except Exception as exc:
218
+ logger.debug("Invalidation publish connection not warmed: %s", exc)
219
+
201
220
  def _log_failure(self, exc: Exception) -> None:
202
221
  """Warn once per outage, then stay quiet about the same outage."""
203
222
  if self._warned:
@@ -22,8 +22,8 @@ if TYPE_CHECKING:
22
22
  from celery import Celery
23
23
 
24
24
  from background_tasks.contracts.schemas import WorkerSnapshot
25
- from background_tasks.invalidation import RedisInvalidationTransport
26
- from background_tasks.settings import BackgroundTasksSettings
25
+ from background_tasks.core.invalidation import RedisInvalidationTransport
26
+ from background_tasks.core.settings import BackgroundTasksSettings
27
27
 
28
28
 
29
29
  @dataclass
@@ -2,7 +2,7 @@
2
2
 
3
3
  Values come from defaults at boot, then get hydrated from the DB by the
4
4
  hosting lifespan before module ``on_startup`` runs. Runtime changes go
5
- through ``settings.reload.apply_changes_and_reload``.
5
+ through ``settings.module_settings.reload.apply_changes_and_reload``.
6
6
 
7
7
  The broker and result-backend URLs are deployment plumbing rather than module
8
8
  config, so they stay env-readable through ``SM_REDIS_URL`` — one variable that
@@ -18,10 +18,12 @@ backend on different Redis databases.
18
18
 
19
19
  ``SM_BG_TASKS_BROKER_URL`` and ``SM_BG_TASKS_RESULT_BACKEND`` still work and
20
20
  take precedence over ``SM_REDIS_URL`` — a deployment that set them meant them —
21
- but log a deprecation warning. Being real env reads, they also beat a stored
22
- value (env → DB → default, GH #486). They are answered by pydantic's own env source
23
- now that ``env_prefix`` is set (GH #283), which is also what stops every other
24
- field being readable from its bare, unprefixed name.
21
+ but log a deprecation warning when they hold a Redis URL (any other transport,
22
+ such as ``memory://``, is theirs to set and logs nothing, GH #868). Being real
23
+ env reads, they also beat a stored value (env → DB → default, GH #486). They
24
+ are answered by pydantic's own env source now that ``env_prefix`` is set
25
+ (GH #283), which is also what stops every other field being readable from its
26
+ bare, unprefixed name.
25
27
 
26
28
  The other env read is ``SM_ENVIRONMENT``, consulted by the
27
29
  ``@model_validator`` to refuse a localhost broker in production — that's a
@@ -40,7 +42,7 @@ from pydantic import Field, ValidationInfo, field_validator, model_validator
40
42
  from pydantic_core import PydanticCustomError
41
43
  from simple_module_core.settings_hydrate import RELATED_FIELDS_CTX
42
44
 
43
- from background_tasks.constants import (
45
+ from background_tasks.core.constants import (
44
46
  DEFAULT_OUTBOX_LEASE_SECONDS,
45
47
  DEFAULT_OUTBOX_MAX_ATTEMPTS,
46
48
  DEFAULT_OUTBOX_SWEEP_INTERVAL_SECONDS,
@@ -48,12 +50,12 @@ from background_tasks.constants import (
48
50
  ENV_PREFIX,
49
51
  max_outbox_handler_timeout,
50
52
  )
51
- from background_tasks.settings_celery import _CELERY_RESTART, CelerySettingsFields
52
- from background_tasks.settings_env_checks import (
53
+ from background_tasks.core.settings_celery import _CELERY_RESTART, CelerySettingsFields
54
+ from background_tasks.core.settings_env_checks import (
53
55
  forbid_localhost_broker_in_production,
54
56
  warn_on_legacy_redis_vars,
55
57
  )
56
- from background_tasks.tracking import TrackingMode
58
+ from background_tasks.core.tracking import TrackingMode
57
59
 
58
60
  __all__ = ["DEFAULT_RETENTION_DAYS", "ENV_PREFIX", "BackgroundTasksSettings"]
59
61
 
@@ -15,8 +15,8 @@ from pydantic_core import PydanticCustomError
15
15
  from pydantic_settings import SettingsConfigDict
16
16
  from simple_module_core.settings_hydrate import RELATED_FIELDS_CTX
17
17
 
18
- from background_tasks.config_guards import parse_task_routes
19
- from background_tasks.constants import (
18
+ from background_tasks.core.config_guards import parse_task_routes
19
+ from background_tasks.core.constants import (
20
20
  DEFAULT_BROKER_URL,
21
21
  DEFAULT_INVALIDATION_CHANNEL,
22
22
  DEFAULT_MAX_RETRIES,
@@ -29,8 +29,8 @@ from background_tasks.constants import (
29
29
  ENV_PREFIX,
30
30
  ENV_REDIS_URL,
31
31
  )
32
- from background_tasks.db_settings import WorkerDatabaseSettings
33
- from background_tasks.settings_logs import LogSinkFields
32
+ from background_tasks.core.db_settings import WorkerDatabaseSettings
33
+ from background_tasks.core.settings_logs import LogSinkFields
34
34
 
35
35
  _CELERY_RESTART = {"requires_restart": True, "group": "Celery"}
36
36
 
@@ -11,10 +11,16 @@ import os
11
11
 
12
12
  from simple_module_core.environments import NON_PROD_ENVIRONMENTS
13
13
 
14
- from background_tasks.constants import ENV_PREFIX, ENV_REDIS_URL
14
+ from background_tasks.core.constants import ENV_PREFIX, ENV_REDIS_URL
15
15
 
16
16
  logger = logging.getLogger("background_tasks.settings")
17
17
 
18
+ # Schemes one SM_REDIS_URL can carry everywhere it is read: Celery's broker and
19
+ # result backend, and redis-py's ``from_url`` behind the rate limiter, leases and
20
+ # the invalidation transport. Celery's ``redis+socket`` and ``sentinel`` fail
21
+ # there, so those values stay on the per-field vars without a warning.
22
+ _REDIS_SCHEMES = frozenset({"redis", "rediss"})
23
+
18
24
 
19
25
  def warn_on_legacy_redis_vars(broker_url: str, result_backend: str) -> None:
20
26
  """Nudge deployments off the per-field names onto ``SM_REDIS_URL``.
@@ -25,12 +31,19 @@ def warn_on_legacy_redis_vars(broker_url: str, result_backend: str) -> None:
25
31
  than in the default factory because ``env_prefix`` means the env source
26
32
  answers these names before any default is consulted, so the factory never
27
33
  sees them.
34
+
35
+ Only a Redis URL is warned about (#868): for anything else, such as the
36
+ in-process ``memory://`` + ``cache+memory://`` pair or an AMQP broker,
37
+ ``SM_REDIS_URL`` can't express the value and these vars are the way to
38
+ set it.
28
39
  """
29
40
  for value, legacy_var in (
30
41
  (broker_url, f"{ENV_PREFIX}BROKER_URL"),
31
42
  (result_backend, f"{ENV_PREFIX}RESULT_BACKEND"),
32
43
  ):
33
- if os.environ.get(legacy_var) == value:
44
+ if os.environ.get(legacy_var) != value:
45
+ continue
46
+ if value.partition("://")[0].lower() in _REDIS_SCHEMES:
34
47
  logger.warning(
35
48
  "%s is deprecated; use %s instead (one URL seeds both the "
36
49
  "broker and the result backend).",
@@ -61,8 +74,8 @@ def forbid_localhost_broker_in_production(broker_url: str, result_backend: str)
61
74
  f"{names} must not point at localhost when SM_ENVIRONMENT={env!r}. "
62
75
  f"Set {ENV_REDIS_URL} on the container to the Redis service host "
63
76
  "(e.g. redis://redis:6379/0) — one URL seeds both the broker and "
64
- f"the result backend. ({env_names} still override it per field, "
65
- "but are deprecated.) These are read before the DB-backed "
66
- "settings exist, so an environment variable is what satisfies "
67
- "this at boot."
77
+ f"the result backend. ({env_names} still override it per field; "
78
+ "they are deprecated for a Redis URL, but stay the way to set any "
79
+ "other transport.) Environment variables are read before the "
80
+ "DB-backed settings exist, so one is what satisfies this at boot."
68
81
  )
@@ -4,7 +4,7 @@ from __future__ import annotations
4
4
 
5
5
  from pydantic import BaseModel, Field, field_validator
6
6
 
7
- from background_tasks.constants import (
7
+ from background_tasks.core.constants import (
8
8
  DEFAULT_LOG_RETENTION_DAYS,
9
9
  DEFAULT_LOG_SINK_LEVEL,
10
10
  LOG_LEVEL_NAMES,
@@ -3,8 +3,12 @@
3
3
  from enum import StrEnum
4
4
  from typing import Any
5
5
 
6
- from background_tasks.constants import INTERNAL_TASK_SWEEP_OUTBOX, SM_TRACKING_HEADER, TaskStatus
7
- from background_tasks.tenant_context import header_of_request
6
+ from background_tasks.core.constants import (
7
+ INTERNAL_TASK_SWEEP_OUTBOX,
8
+ SM_TRACKING_HEADER,
9
+ TaskStatus,
10
+ )
11
+ from background_tasks.executions.tenant_context import header_of_request
8
12
 
9
13
 
10
14
  class TrackingMode(StrEnum):
@@ -0,0 +1,5 @@
1
+ """Task executions as the app sees them.
2
+
3
+ Enqueue after commit, carrying the request tenant, the admin listing service,
4
+ filters and retries.
5
+ """
@@ -12,7 +12,7 @@ from simple_module_db import LIKE_ESCAPE_CHAR, like_contains_pattern
12
12
  from sqlalchemy import ColumnElement, select
13
13
  from sqlmodel import col
14
14
 
15
- from background_tasks.constants import PLATFORM_TENANT_FILTER, RETRYABLE_STATUSES, TaskStatus
15
+ from background_tasks.core.constants import PLATFORM_TENANT_FILTER, RETRYABLE_STATUSES, TaskStatus
16
16
  from background_tasks.models import TaskExecution
17
17
 
18
18
  Conditions = list[ColumnElement[bool]]
@@ -1,6 +1,6 @@
1
1
  """Re-enqueueing work: one execution, or a filtered sweep of them.
2
2
 
3
- Split from :mod:`background_tasks.service` because re-enqueueing is the only
3
+ Split from :mod:`background_tasks.executions.service` because re-enqueueing is the only
4
4
  thing in this module that writes to the broker, and it is where every
5
5
  correctness question lives — what may be retried, how many at once, and what
6
6
  must not happen twice. The read paths have none of those questions.
@@ -20,17 +20,17 @@ from simple_module_db import RequestSession, all_tenants, tenant_context
20
20
  from sqlalchemy import Select, func, select, update
21
21
  from sqlmodel import col
22
22
 
23
- from background_tasks._signal_support import now_utc
24
- from background_tasks.after_commit import after_commit
25
- from background_tasks.constants import RETRY_ALL_BATCH, SM_TRACKING_HEADER, TaskStatus
26
23
  from background_tasks.contracts.events import TaskRetried
27
24
  from background_tasks.contracts.schemas import RetryFailedResult
28
- from background_tasks.filters import Conditions, bulk_retry_conditions
25
+ from background_tasks.core.constants import RETRY_ALL_BATCH, SM_TRACKING_HEADER, TaskStatus
26
+ from background_tasks.core.sync_db import sync_session
27
+ from background_tasks.core.tracking import TrackingMode
28
+ from background_tasks.executions.after_commit import after_commit
29
+ from background_tasks.executions.filters import Conditions, bulk_retry_conditions
30
+ from background_tasks.executions.tenant_context import publish_as_owner
29
31
  from background_tasks.models import TaskExecution
30
- from background_tasks.sync_db import sync_session
31
- from background_tasks.task_resource import resource_headers
32
- from background_tasks.tenant_context import publish_as_owner
33
- from background_tasks.tracking import TrackingMode
32
+ from background_tasks.worker._signal_support import now_utc
33
+ from background_tasks.worker.task_resource import resource_headers
34
34
 
35
35
  if TYPE_CHECKING:
36
36
  from celery import Celery
@@ -43,7 +43,7 @@ def claim_query(conditions: Conditions, batch: int) -> Select[tuple[TaskExecutio
43
43
 
44
44
  ``FOR UPDATE SKIP LOCKED`` is what makes two simultaneous sweeps disjoint.
45
45
  The guard that is *supposed* to keep a row out of a second sweep —
46
- :func:`~background_tasks.filters.bulk_retry_conditions` excluding parents
46
+ :func:`~background_tasks.executions.filters.bulk_retry_conditions` excluding parents
47
47
  that already have a child — only starts working once the child row exists,
48
48
  and a concurrent sweep reads the same batch long before that. Locking the
49
49
  parents makes the second reader skip them instead of publishing the same
@@ -3,25 +3,25 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import uuid
6
- from collections.abc import Sequence
7
6
  from datetime import UTC, datetime, timedelta
8
7
  from typing import TYPE_CHECKING
9
8
 
10
9
  from fastapi import HTTPException, status
11
10
  from simple_module_core.events import EventBus
12
11
  from simple_module_db import RequestSession
13
- from sqlalchemy import Row, func, select
12
+ from simple_module_db.pagination import total_pages
13
+ from sqlalchemy import func, select
14
14
 
15
- from background_tasks.constants import RETRYABLE_STATUSES, TaskStatus
16
15
  from background_tasks.contracts.schemas import (
17
16
  RetryFailedResult,
18
17
  TaskExecutionDetail,
19
18
  TaskExecutionListItem,
20
19
  TaskExecutionListResponse,
21
20
  )
22
- from background_tasks.filters import execution_filters
23
- from background_tasks.models import TaskExecution
24
- from background_tasks.retry_service import RetryCoordinator
21
+ from background_tasks.core.constants import RETRYABLE_STATUSES, TaskStatus
22
+ from background_tasks.executions.filters import execution_filters
23
+ from background_tasks.executions.retry_service import RetryCoordinator
24
+ from background_tasks.models import TaskExecution, dto_columns, newest_first
25
25
 
26
26
  if TYPE_CHECKING:
27
27
  from celery import Celery
@@ -70,36 +70,22 @@ class BackgroundTaskService:
70
70
  status=status, task_name=task_name, queue=queue, tenant_id=tenant_id
71
71
  )
72
72
 
73
- # A window-function total lets us fetch the page and the count in a
74
- # single round trip. SQLAlchemy's ``AsyncSession`` serialises calls on
75
- # one connection, so ``asyncio.gather`` wouldn't help here.
76
- async def fetch(p: int) -> tuple[Sequence[Row[tuple[TaskExecution, int]]], int]:
77
- total_col = func.count().over().label("_total")
78
- query = (
79
- select(TaskExecution, total_col)
80
- .where(*conditions)
81
- .order_by(TaskExecution.queued_at.desc().nulls_last())
82
- .offset((p - 1) * per_page)
83
- .limit(per_page)
84
- )
85
- rows = (await self.db.execute(query)).all()
86
- return rows, (int(rows[0][1]) if rows else 0)
87
-
88
- rows, total = await fetch(page)
89
- if not rows and page > 1:
90
- # The window-function total only rides along on a row that's
91
- # actually returned, so a page past the end (stale bookmark, a
92
- # manually-edited ?page=) can't self-report the real total — it
93
- # looks identical to "there are no rows at all". Count for real,
94
- # clamp to the last valid page, and refetch so callers never see
95
- # a false "nothing exists" for a query that has rows elsewhere.
96
- count_query = select(func.count()).select_from(TaskExecution).where(*conditions)
97
- real_total = int((await self.db.execute(count_query)).scalar_one())
98
- if real_total:
99
- page = max(1, -(-real_total // per_page)) # ceil division
100
- rows, total = await fetch(page)
101
-
102
- items = [TaskExecutionListItem.model_validate(row[0]) for row in rows]
73
+ count_query = select(func.count()).select_from(TaskExecution).where(*conditions)
74
+ total = int((await self.db.execute(count_query)).scalar_one())
75
+ if total:
76
+ page = min(page, total_pages(total, per_page))
77
+
78
+ query = (
79
+ select(TaskExecution)
80
+ .options(dto_columns(TaskExecutionListItem))
81
+ .where(*conditions)
82
+ # The expression index preserves DESC NULLS LAST on both DBs.
83
+ .order_by(*newest_first(TaskExecution.queued_at))
84
+ .offset((page - 1) * per_page)
85
+ .limit(per_page)
86
+ )
87
+ rows = (await self.db.execute(query)).scalars().all()
88
+ items = [TaskExecutionListItem.model_validate(row) for row in rows]
103
89
 
104
90
  return TaskExecutionListResponse(
105
91
  items=items,
@@ -112,6 +98,11 @@ class BackgroundTaskService:
112
98
  tenant_id=tenant_id,
113
99
  )
114
100
 
101
+ async def has_any(self) -> bool:
102
+ """Whether any execution exists at all: an index-friendly probe, no COUNT."""
103
+ probe = select(TaskExecution.id).limit(1)
104
+ return (await self.db.execute(probe)).first() is not None
105
+
115
106
  async def status_counts(
116
107
  self,
117
108
  *,
@@ -20,7 +20,7 @@ from typing import Any
20
20
  from simple_module_db import TenantIsolationError, current_tenant_id, is_valid_tenant_id
21
21
  from simple_module_db.listeners import current_user_id
22
22
 
23
- from background_tasks.constants import OWNER_ID_MAX_LENGTH
23
+ from background_tasks.core.constants import OWNER_ID_MAX_LENGTH
24
24
 
25
25
  TENANT_HEADER = "sm_tenant_id"
26
26
  OWNER_HEADER = "sm_owner_id"
@@ -174,7 +174,11 @@ def restore_tenant(*, task_id: str | None, task: Any) -> None:
174
174
  # context, so without headers it keeps the caller's tenant and owner.
175
175
  eager = bool(getattr(getattr(task, "request", None), "is_eager", False))
176
176
  tenant = _tenant_of(task) or (current_tenant_id.get() if eager else _default_tenant)
177
- owner = message_owner(task=task) or (_task_owner.get() if eager else "") # "": no owner
177
+ # ``""`` (not ``None``) means "no owner" and stops :func:`stamp_owner`
178
+ # falling through to an ambient ``current_user_id``. A worker prerun sets it
179
+ # afresh, so a stranded binding never reaches the next task's messages (an
180
+ # eager run deliberately inherits its caller's).
181
+ owner = message_owner(task=task) or (_task_owner.get() if eager else "")
178
182
  owner_token = _task_owner.set(owner)
179
183
  tenant_token = current_tenant_id.set(tenant)
180
184
  _tokens.set((*_tokens.get(), (task_id, tenant_token, owner_token)))
@@ -125,7 +125,9 @@
125
125
  "no_workers_title": "Kein Worker läuft",
126
126
  "no_workers_description": "Der Broker ist verfügbar, aber kein Worker verarbeitet die Warteschlange. Jetzt eingereihte Aufgaben warten auf ihre Ausführung.",
127
127
  "healthy_title": "Noch keine Aufgabe ausgeführt",
128
- "healthy_description": "Registrierte Aufgaben erscheinen hier bei ihrer ersten Ausführung."
128
+ "healthy_description": "Registrierte Aufgaben erscheinen hier bei ihrer ersten Ausführung.",
129
+ "checking_title": "Suche nach Workern…",
130
+ "checking_description": "Der Broker wird gefragt, ob etwas läuft, das Aufgaben ausführt."
129
131
  },
130
132
  "workers": {
131
133
  "title": "Worker",
@@ -155,7 +157,9 @@
155
157
  "routes_module": "Festgelegt durch",
156
158
  "routes_override": "Betreiberüberschreibung",
157
159
  "routes_default_queue": "Standardwarteschlange",
158
- "routes_empty": "Keine Aufgabenrouten konfiguriert. Jede Aufgabe wird an die Standardwarteschlange gesendet. Fügen Sie Routen in task_config.py (TASK_ROUTES) eines Moduls hinzu."
160
+ "routes_empty": "Keine Aufgabenrouten konfiguriert. Jede Aufgabe wird an die Standardwarteschlange gesendet. Fügen Sie Routen in task_config.py (TASK_ROUTES) eines Moduls hinzu.",
161
+ "checking": "Broker wird abgefragt…",
162
+ "checking_label": "Worker werden geladen"
159
163
  },
160
164
  "nav": {
161
165
  "background_tasks": "Hintergrundaufgaben",