simple-module-background-tasks 0.0.42__tar.gz → 0.0.44__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 (217) hide show
  1. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/.gitignore +3 -0
  2. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/PKG-INFO +7 -7
  3. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/README.md +1 -1
  4. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/__init__.py +9 -9
  5. simple_module_background_tasks-0.0.44/background_tasks/celery_app.py +13 -0
  6. simple_module_background_tasks-0.0.44/background_tasks/config_guards.py +17 -0
  7. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/contracts/outbox.py +1 -1
  8. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/contracts/schemas.py +1 -1
  9. simple_module_background_tasks-0.0.44/background_tasks/core/__init__.py +7 -0
  10. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/core}/_lifecycle.py +17 -17
  11. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/core}/config_guards.py +1 -1
  12. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/core}/services.py +2 -2
  13. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/core}/settings.py +5 -5
  14. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/core}/settings_celery.py +4 -4
  15. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/core}/settings_env_checks.py +1 -1
  16. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/core}/settings_logs.py +1 -1
  17. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/core}/tracking.py +6 -2
  18. simple_module_background_tasks-0.0.44/background_tasks/executions/__init__.py +5 -0
  19. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/executions}/after_commit.py +13 -3
  20. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/executions}/filters.py +1 -1
  21. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/executions}/retry_service.py +14 -12
  22. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/executions}/service.py +27 -36
  23. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/executions}/tenant_context.py +32 -22
  24. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/locales/de.json +6 -2
  25. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/locales/en.json +6 -2
  26. simple_module_background_tasks-0.0.44/background_tasks/logs/__init__.py +4 -0
  27. simple_module_background_tasks-0.0.42/background_tasks/log_service.py → simple_module_background_tasks-0.0.44/background_tasks/logs/service.py +1 -1
  28. simple_module_background_tasks-0.0.42/background_tasks/log_sink.py → simple_module_background_tasks-0.0.44/background_tasks/logs/sink.py +5 -5
  29. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/models.py +27 -3
  30. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/module.py +13 -13
  31. simple_module_background_tasks-0.0.44/background_tasks/outbox/__init__.py +5 -0
  32. simple_module_background_tasks-0.0.42/background_tasks/outbox_claim.py → simple_module_background_tasks-0.0.44/background_tasks/outbox/claim.py +2 -2
  33. simple_module_background_tasks-0.0.42/background_tasks/outbox_dispatch.py → simple_module_background_tasks-0.0.44/background_tasks/outbox/dispatch.py +4 -4
  34. simple_module_background_tasks-0.0.42/background_tasks/outbox_service.py → simple_module_background_tasks-0.0.44/background_tasks/outbox/service.py +3 -3
  35. simple_module_background_tasks-0.0.42/background_tasks/outbox_support.py → simple_module_background_tasks-0.0.44/background_tasks/outbox/support.py +2 -2
  36. simple_module_background_tasks-0.0.42/background_tasks/outbox_sweep.py → simple_module_background_tasks-0.0.44/background_tasks/outbox/sweep.py +3 -3
  37. simple_module_background_tasks-0.0.42/background_tasks/outbox_transport.py → simple_module_background_tasks-0.0.44/background_tasks/outbox/transport.py +6 -6
  38. simple_module_background_tasks-0.0.42/background_tasks/outbox_worker.py → simple_module_background_tasks-0.0.44/background_tasks/outbox/worker.py +8 -8
  39. simple_module_background_tasks-0.0.44/background_tasks/outbox_transport.py +15 -0
  40. simple_module_background_tasks-0.0.44/background_tasks/outbox_worker.py +15 -0
  41. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/pages/Detail.tsx +11 -11
  42. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/pages/Index.tsx +23 -13
  43. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/pages/Logs.tsx +6 -6
  44. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/pages/Outbox.tsx +5 -5
  45. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/pages/Workers.tsx +36 -14
  46. simple_module_background_tasks-0.0.44/background_tasks/runner.py +13 -0
  47. simple_module_background_tasks-0.0.44/background_tasks/settings.py +15 -0
  48. simple_module_background_tasks-0.0.44/background_tasks/sync_db.py +15 -0
  49. simple_module_background_tasks-0.0.44/background_tasks/task_routing.py +17 -0
  50. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/tasks.py +27 -11
  51. simple_module_background_tasks-0.0.44/background_tasks/tenant_context.py +17 -0
  52. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/DetailFacts.tsx +1 -1
  53. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/ExecutionRow.tsx +2 -2
  54. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/ExecutionsTable.tsx +1 -1
  55. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/LogLevelSelect.tsx +1 -1
  56. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/LogTable.tsx +2 -2
  57. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/LogsPanel.tsx +1 -1
  58. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/OutboxTable.tsx +2 -2
  59. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/PayloadCards.tsx +1 -1
  60. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/ProgressCard.tsx +1 -1
  61. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/RetryAllDialog.tsx +1 -1
  62. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/RetryConfirmDialog.tsx +1 -1
  63. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/RoutesTable.tsx +1 -1
  64. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/StatusPill.tsx +1 -1
  65. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/StatusStrip.tsx +1 -1
  66. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/TaskFilters.tsx +1 -1
  67. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/TasksEmpty.tsx +46 -31
  68. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/WorkerCard.tsx +29 -1
  69. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/WorkerHealthBanner.tsx +3 -3
  70. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui/utils}/constants.ts +3 -1
  71. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui/utils}/logs.ts +1 -1
  72. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui/utils}/outbox.ts +1 -1
  73. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui/utils}/retry.ts +1 -1
  74. simple_module_background_tasks-0.0.44/background_tasks/web/__init__.py +1 -0
  75. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/web}/deps.py +4 -4
  76. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/web}/endpoints/api_admin.py +10 -10
  77. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/web}/endpoints/api_status.py +8 -3
  78. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/web}/endpoints/logs_api.py +9 -4
  79. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/web}/endpoints/logs_views.py +3 -3
  80. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/web}/endpoints/outbox_api.py +4 -4
  81. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/web}/endpoints/outbox_views.py +3 -3
  82. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/web}/endpoints/views.py +29 -20
  83. simple_module_background_tasks-0.0.44/background_tasks/worker/__init__.py +6 -0
  84. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/worker}/_signal_support.py +30 -14
  85. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/worker}/celery_app.py +8 -7
  86. simple_module_background_tasks-0.0.42/background_tasks/workers_state.py → simple_module_background_tasks-0.0.44/background_tasks/worker/fleet_state.py +1 -1
  87. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/worker}/log_context.py +12 -15
  88. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/worker}/runner.py +7 -7
  89. simple_module_background_tasks-0.0.42/background_tasks/worker_settings.py → simple_module_background_tasks-0.0.44/background_tasks/worker/settings.py +3 -3
  90. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/worker}/signals.py +24 -18
  91. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/worker}/task_heartbeat.py +5 -5
  92. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/worker}/task_resource.py +2 -2
  93. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/worker}/task_routing.py +2 -2
  94. simple_module_background_tasks-0.0.44/background_tasks/worker/tenant_celery.py +85 -0
  95. simple_module_background_tasks-0.0.44/background_tasks/worker_settings.py +15 -0
  96. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/package.json +1 -1
  97. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/pyproject.toml +6 -6
  98. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/tests/conftest.py +17 -2
  99. simple_module_background_tasks-0.0.42/tests/test_bg_redis_health.py → simple_module_background_tasks-0.0.44/tests/core/health/test_background_tasks_redis_health.py +1 -1
  100. simple_module_background_tasks-0.0.42/tests/test_bg_invalidation.py → simple_module_background_tasks-0.0.44/tests/core/invalidation/test_background_tasks_invalidation.py +4 -4
  101. simple_module_background_tasks-0.0.42/tests/test_bg_invalidation_degraded.py → simple_module_background_tasks-0.0.44/tests/core/invalidation/test_background_tasks_invalidation_degraded.py +5 -5
  102. simple_module_background_tasks-0.0.42/tests/test_bg_invalidation_redis.py → simple_module_background_tasks-0.0.44/tests/core/invalidation/test_background_tasks_invalidation_redis.py +3 -3
  103. simple_module_background_tasks-0.0.42/tests/test_beat_schedule.py → simple_module_background_tasks-0.0.44/tests/core/settings/test_background_tasks_beat_schedule.py +3 -3
  104. simple_module_background_tasks-0.0.42/tests/test_bg_config_guards.py → simple_module_background_tasks-0.0.44/tests/core/settings/test_background_tasks_config_guards.py +5 -5
  105. simple_module_background_tasks-0.0.42/tests/test_bg_db_timeouts.py → simple_module_background_tasks-0.0.44/tests/core/settings/test_background_tasks_db_timeouts.py +4 -3
  106. simple_module_background_tasks-0.0.42/tests/test_bg_redis_url.py → simple_module_background_tasks-0.0.44/tests/core/settings/test_background_tasks_redis_url.py +2 -2
  107. {simple_module_background_tasks-0.0.42/tests → simple_module_background_tasks-0.0.44/tests/core/settings}/test_background_tasks_settings.py +5 -5
  108. simple_module_background_tasks-0.0.42/tests/test_bg_settings_env.py → simple_module_background_tasks-0.0.44/tests/core/settings/test_background_tasks_settings_env.py +2 -2
  109. simple_module_background_tasks-0.0.42/tests/test_sync_db.py → simple_module_background_tasks-0.0.44/tests/core/sync_db/test_background_tasks_sync_db.py +1 -1
  110. simple_module_background_tasks-0.0.42/tests/test_sync_db_fork.py → simple_module_background_tasks-0.0.44/tests/core/sync_db/test_background_tasks_sync_db_fork.py +1 -1
  111. simple_module_background_tasks-0.0.42/tests/test_retry_failed_bulk.py → simple_module_background_tasks-0.0.44/tests/executions/retry/test_background_tasks_retry_failed_bulk.py +1 -1
  112. simple_module_background_tasks-0.0.42/tests/test_retry_failed_guards.py → simple_module_background_tasks-0.0.44/tests/executions/retry/test_background_tasks_retry_failed_guards.py +2 -2
  113. simple_module_background_tasks-0.0.42/tests/test_retry_sweep_ordering.py → simple_module_background_tasks-0.0.44/tests/executions/retry/test_background_tasks_retry_sweep_ordering.py +3 -3
  114. {simple_module_background_tasks-0.0.42/tests → simple_module_background_tasks-0.0.44/tests/executions/service}/test_background_tasks_after_commit.py +5 -4
  115. simple_module_background_tasks-0.0.44/tests/executions/service/test_background_tasks_eager_bindings.py +65 -0
  116. simple_module_background_tasks-0.0.42/tests/test_bg_index_has_executions.py → simple_module_background_tasks-0.0.44/tests/executions/service/test_background_tasks_index_has_executions.py +1 -1
  117. simple_module_background_tasks-0.0.42/tests/test_bg_list_item_payload.py → simple_module_background_tasks-0.0.44/tests/executions/service/test_background_tasks_list_item_payload.py +1 -1
  118. simple_module_background_tasks-0.0.44/tests/executions/service/test_background_tasks_newest_first_status.py +53 -0
  119. simple_module_background_tasks-0.0.44/tests/executions/service/test_background_tasks_order_index.py +90 -0
  120. simple_module_background_tasks-0.0.44/tests/executions/service/test_background_tasks_publish_validation.py +73 -0
  121. simple_module_background_tasks-0.0.44/tests/executions/service/test_background_tasks_read_projection.py +107 -0
  122. simple_module_background_tasks-0.0.44/tests/executions/service/test_background_tasks_retention_retries.py +88 -0
  123. simple_module_background_tasks-0.0.44/tests/executions/service/test_background_tasks_savepoint_publish.py +55 -0
  124. simple_module_background_tasks-0.0.42/tests/test_bg_service.py → simple_module_background_tasks-0.0.44/tests/executions/service/test_background_tasks_service.py +2 -2
  125. {simple_module_background_tasks-0.0.42/tests → simple_module_background_tasks-0.0.44/tests/executions/service}/test_background_tasks_tz_columns.py +2 -2
  126. simple_module_background_tasks-0.0.42/tests/test_bg_log_purge.py → simple_module_background_tasks-0.0.44/tests/logs/purge/test_background_tasks_log_purge.py +4 -2
  127. simple_module_background_tasks-0.0.42/tests/test_log_context.py → simple_module_background_tasks-0.0.44/tests/logs/sink/test_background_tasks_log_context.py +4 -4
  128. simple_module_background_tasks-0.0.42/tests/test_bg_log_sink.py → simple_module_background_tasks-0.0.44/tests/logs/sink/test_background_tasks_log_sink.py +4 -3
  129. simple_module_background_tasks-0.0.42/tests/test_bg_log_sink_loop.py → simple_module_background_tasks-0.0.44/tests/logs/sink/test_background_tasks_log_sink_loop.py +3 -2
  130. simple_module_background_tasks-0.0.42/tests/test_bg_log_sink_nul.py → simple_module_background_tasks-0.0.44/tests/logs/sink/test_background_tasks_log_sink_nul.py +1 -1
  131. simple_module_background_tasks-0.0.42/tests/test_outbox_admin.py → simple_module_background_tasks-0.0.44/tests/outbox/admin/test_background_tasks_outbox_admin.py +3 -3
  132. simple_module_background_tasks-0.0.42/tests/test_outbox_tenancy.py → simple_module_background_tasks-0.0.44/tests/outbox/admin/test_background_tasks_outbox_tenancy.py +1 -1
  133. {simple_module_background_tasks-0.0.42/tests → simple_module_background_tasks-0.0.44/tests/outbox/delivery}/test_background_tasks_delivery_context.py +2 -2
  134. simple_module_background_tasks-0.0.42/tests/test_bg_inprocess_sweep.py → simple_module_background_tasks-0.0.44/tests/outbox/delivery/test_background_tasks_inprocess_sweep.py +5 -5
  135. simple_module_background_tasks-0.0.42/tests/test_outbox_concurrency.py → simple_module_background_tasks-0.0.44/tests/outbox/delivery/test_background_tasks_outbox_concurrency.py +3 -3
  136. simple_module_background_tasks-0.0.42/tests/test_outbox_delivery.py → simple_module_background_tasks-0.0.44/tests/outbox/delivery/test_background_tasks_outbox_delivery.py +4 -4
  137. simple_module_background_tasks-0.0.42/tests/test_bg_outbox_eager_platform.py → simple_module_background_tasks-0.0.44/tests/outbox/delivery/test_background_tasks_outbox_eager_platform.py +3 -3
  138. simple_module_background_tasks-0.0.42/tests/test_bg_outbox_eager_serialization.py → simple_module_background_tasks-0.0.44/tests/outbox/delivery/test_background_tasks_outbox_eager_serialization.py +1 -1
  139. simple_module_background_tasks-0.0.42/tests/test_bg_outbox_fence_guard.py → simple_module_background_tasks-0.0.44/tests/outbox/delivery/test_background_tasks_outbox_fence_guard.py +3 -3
  140. simple_module_background_tasks-0.0.42/tests/test_bg_outbox_guard_savepoint.py → simple_module_background_tasks-0.0.44/tests/outbox/delivery/test_background_tasks_outbox_guard_savepoint.py +4 -4
  141. simple_module_background_tasks-0.0.42/tests/test_bg_outbox_publish_scope.py → simple_module_background_tasks-0.0.44/tests/outbox/delivery/test_background_tasks_outbox_publish_scope.py +3 -3
  142. simple_module_background_tasks-0.0.42/tests/test_bg_outbox_retry_policy.py → simple_module_background_tasks-0.0.44/tests/outbox/delivery/test_background_tasks_outbox_retry_policy.py +5 -5
  143. simple_module_background_tasks-0.0.42/tests/test_bg_outbox_swallowed_cancel.py → simple_module_background_tasks-0.0.44/tests/outbox/delivery/test_background_tasks_outbox_swallowed_cancel.py +3 -3
  144. simple_module_background_tasks-0.0.42/tests/test_bg_outbox_worker_chain.py → simple_module_background_tasks-0.0.44/tests/outbox/delivery/test_background_tasks_outbox_worker_chain.py +7 -5
  145. simple_module_background_tasks-0.0.42/tests/test_outbox_worker_task.py → simple_module_background_tasks-0.0.44/tests/outbox/delivery/test_background_tasks_outbox_worker_task.py +5 -4
  146. simple_module_background_tasks-0.0.42/tests/test_bg_outbox_loop_interrupt.py → simple_module_background_tasks-0.0.44/tests/outbox/loop/test_background_tasks_outbox_loop_interrupt.py +1 -1
  147. simple_module_background_tasks-0.0.42/tests/test_bg_outbox_thread_loops.py → simple_module_background_tasks-0.0.44/tests/outbox/loop/test_background_tasks_outbox_thread_loops.py +3 -2
  148. simple_module_background_tasks-0.0.42/tests/test_admin_api.py → simple_module_background_tasks-0.0.44/tests/web/api/test_background_tasks_admin_api.py +1 -1
  149. simple_module_background_tasks-0.0.42/tests/test_detail_props.py → simple_module_background_tasks-0.0.44/tests/web/api/test_background_tasks_detail_props.py +1 -1
  150. simple_module_background_tasks-0.0.42/tests/test_index_filters.py → simple_module_background_tasks-0.0.44/tests/web/api/test_background_tasks_index_filters.py +1 -1
  151. simple_module_background_tasks-0.0.42/tests/test_bg_page_clamp.py → simple_module_background_tasks-0.0.44/tests/web/api/test_background_tasks_page_clamp.py +1 -1
  152. simple_module_background_tasks-0.0.42/tests/test_bg_task_status_api.py → simple_module_background_tasks-0.0.44/tests/web/api/test_background_tasks_task_status_api.py +1 -1
  153. simple_module_background_tasks-0.0.42/tests/test_bg_users_ordering.py → simple_module_background_tasks-0.0.44/tests/web/api/test_background_tasks_users_ordering.py +1 -1
  154. simple_module_background_tasks-0.0.42/tests/test_bg_index_worker_presence.py → simple_module_background_tasks-0.0.44/tests/worker/inspector/test_background_tasks_index_worker_presence.py +46 -13
  155. simple_module_background_tasks-0.0.42/tests/test_worker_inspector.py → simple_module_background_tasks-0.0.44/tests/worker/inspector/test_background_tasks_worker_inspector.py +7 -7
  156. simple_module_background_tasks-0.0.42/tests/test_workers_endpoints.py → simple_module_background_tasks-0.0.44/tests/worker/inspector/test_background_tasks_workers_endpoints.py +8 -6
  157. simple_module_background_tasks-0.0.42/tests/test_workers_uptime.py → simple_module_background_tasks-0.0.44/tests/worker/inspector/test_background_tasks_workers_uptime.py +12 -10
  158. simple_module_background_tasks-0.0.42/tests/test_bg_routes_override_api.py → simple_module_background_tasks-0.0.44/tests/worker/runner/test_background_tasks_routes_override_api.py +3 -3
  159. simple_module_background_tasks-0.0.42/tests/test_bg_runner_settings.py → simple_module_background_tasks-0.0.44/tests/worker/runner/test_background_tasks_runner_settings.py +8 -8
  160. simple_module_background_tasks-0.0.42/tests/test_bg_task_routing.py → simple_module_background_tasks-0.0.44/tests/worker/runner/test_background_tasks_task_routing.py +5 -5
  161. simple_module_background_tasks-0.0.42/tests/test_bg_worker_settings.py → simple_module_background_tasks-0.0.44/tests/worker/runner/test_background_tasks_worker_settings.py +2 -2
  162. simple_module_background_tasks-0.0.44/tests/worker/signals/test_background_tasks_argument_json.py +131 -0
  163. simple_module_background_tasks-0.0.44/tests/worker/signals/test_background_tasks_execution_bindings.py +110 -0
  164. {simple_module_background_tasks-0.0.42/tests → simple_module_background_tasks-0.0.44/tests/worker/signals}/test_background_tasks_heartbeat.py +4 -3
  165. simple_module_background_tasks-0.0.42/tests/test_bg_quiet_sweep_unrecorded.py → simple_module_background_tasks-0.0.44/tests/worker/signals/test_background_tasks_quiet_sweep_unrecorded.py +5 -5
  166. {simple_module_background_tasks-0.0.42/tests → simple_module_background_tasks-0.0.44/tests/worker/signals}/test_background_tasks_resource_status.py +1 -1
  167. {simple_module_background_tasks-0.0.42/tests → simple_module_background_tasks-0.0.44/tests/worker/signals}/test_background_tasks_resource_transport.py +6 -6
  168. simple_module_background_tasks-0.0.44/tests/worker/signals/test_background_tasks_result_json.py +81 -0
  169. simple_module_background_tasks-0.0.42/tests/test_signal_tenant_stamp.py → simple_module_background_tasks-0.0.44/tests/worker/signals/test_background_tasks_signal_tenant_stamp.py +3 -3
  170. simple_module_background_tasks-0.0.42/tests/test_signals.py → simple_module_background_tasks-0.0.44/tests/worker/signals/test_background_tasks_signals.py +10 -6
  171. simple_module_background_tasks-0.0.42/tests/test_sweep_stuck.py → simple_module_background_tasks-0.0.44/tests/worker/signals/test_background_tasks_sweep_stuck.py +2 -2
  172. simple_module_background_tasks-0.0.42/tests/test_bg_task_progress.py → simple_module_background_tasks-0.0.44/tests/worker/signals/test_background_tasks_task_progress.py +6 -5
  173. simple_module_background_tasks-0.0.42/tests/test_bg_task_progress_audit.py → simple_module_background_tasks-0.0.44/tests/worker/signals/test_background_tasks_task_progress_audit.py +4 -3
  174. {simple_module_background_tasks-0.0.42/tests → simple_module_background_tasks-0.0.44/tests/worker/signals}/test_background_tasks_tracking_modes.py +11 -11
  175. simple_module_background_tasks-0.0.42/tests/test_bg_worker_audit.py → simple_module_background_tasks-0.0.44/tests/worker/signals/test_background_tasks_worker_audit.py +4 -4
  176. simple_module_background_tasks-0.0.42/tests/test_bg_worker_audit_bookkeeping.py → simple_module_background_tasks-0.0.44/tests/worker/signals/test_background_tasks_worker_audit_bookkeeping.py +3 -3
  177. simple_module_background_tasks-0.0.44/tests/worker/tenancy/test_background_tasks_custom_bases.py +109 -0
  178. simple_module_background_tasks-0.0.42/tests/test_execution_tenancy.py → simple_module_background_tasks-0.0.44/tests/worker/tenancy/test_background_tasks_execution_tenancy.py +5 -5
  179. simple_module_background_tasks-0.0.42/tests/test_tenant_context.py → simple_module_background_tasks-0.0.44/tests/worker/tenancy/test_background_tasks_tenant_context.py +32 -1
  180. {simple_module_background_tasks-0.0.42/tests → simple_module_background_tasks-0.0.44/tests/worker/tenancy}/test_background_tasks_worker_tenancy.py +1 -1
  181. simple_module_background_tasks-0.0.42/tests/test_worker_tenancy.py → simple_module_background_tasks-0.0.44/tests/worker/tenancy/test_background_tasks_worker_tenancy_context.py +4 -3
  182. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/tests-js/background_tasks_DetailPage.test.tsx +1 -1
  183. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/tests-js/background_tasks_IndexPage.test.tsx +20 -1
  184. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/tests-js/background_tasks_LogsTab.test.tsx +1 -1
  185. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/tests-js/background_tasks_OutboxPage.test.tsx +1 -1
  186. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/tests-js/background_tasks_WorkerHealthBanner.test.tsx +1 -1
  187. simple_module_background_tasks-0.0.44/tests-js/background_tasks_WorkersPage.test.tsx +89 -0
  188. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/tests-js/outbox.test.ts +1 -1
  189. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/tests-js/retry.test.ts +1 -1
  190. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/tests-js/task-formatters.test.ts +1 -1
  191. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/LICENSE +0 -0
  192. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/contracts/__init__.py +0 -0
  193. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/contracts/events.py +0 -0
  194. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/contracts/logs.py +0 -0
  195. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/core}/constants.py +0 -0
  196. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/core}/db_settings.py +0 -0
  197. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/core}/health.py +0 -0
  198. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/core}/invalidation.py +0 -0
  199. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/core}/sync_db.py +0 -0
  200. /simple_module_background_tasks-0.0.42/background_tasks/log_purge.py → /simple_module_background_tasks-0.0.44/background_tasks/logs/purge.py +0 -0
  201. /simple_module_background_tasks-0.0.42/background_tasks/outbox_clock.py → /simple_module_background_tasks-0.0.44/background_tasks/outbox/clock.py +0 -0
  202. /simple_module_background_tasks-0.0.42/background_tasks/outbox_guard.py → /simple_module_background_tasks-0.0.44/background_tasks/outbox/guard.py +0 -0
  203. /simple_module_background_tasks-0.0.42/background_tasks/outbox_loop.py → /simple_module_background_tasks-0.0.44/background_tasks/outbox/loop.py +0 -0
  204. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/pages/api.generated.ts +0 -0
  205. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/pages/api.ts +0 -0
  206. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/background_tasks/py.typed +0 -0
  207. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/TracebackCard.tsx +0 -0
  208. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui}/components/WorkerEmptyStates.tsx +0 -0
  209. {simple_module_background_tasks-0.0.42/background_tasks/pages → simple_module_background_tasks-0.0.44/background_tasks/ui/utils}/worker-health.ts +0 -0
  210. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/web}/endpoints/__init__.py +0 -0
  211. {simple_module_background_tasks-0.0.42/background_tasks → simple_module_background_tasks-0.0.44/background_tasks/worker}/_signal_bus.py +0 -0
  212. /simple_module_background_tasks-0.0.42/background_tasks/worker_inspector.py → /simple_module_background_tasks-0.0.44/background_tasks/worker/inspector.py +0 -0
  213. /simple_module_background_tasks-0.0.42/tests/test_bg_startup_log_masking.py → /simple_module_background_tasks-0.0.44/tests/core/settings/test_background_tasks_startup_log_masking.py +0 -0
  214. /simple_module_background_tasks-0.0.42/tests/test_bg_log_api.py → /simple_module_background_tasks-0.0.44/tests/web/api/test_background_tasks_log_api.py +0 -0
  215. /simple_module_background_tasks-0.0.42/tests/test_bg_pagination_bounds.py → /simple_module_background_tasks-0.0.44/tests/web/api/test_background_tasks_pagination_bounds.py +0 -0
  216. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/tests-js/stub-fetch.ts +0 -0
  217. {simple_module_background_tasks-0.0.42 → simple_module_background_tasks-0.0.44}/tsconfig.json +0 -0
@@ -22,6 +22,9 @@ node_modules/
22
22
 
23
23
  # Database
24
24
  *.db
25
+ *.db-wal
26
+ *.db-shm
27
+ *.db-journal
25
28
  *.sqlite3
26
29
 
27
30
  # Module-managed runtime state (e.g. uploaded dataset files,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: simple_module_background_tasks
3
- Version: 0.0.42
3
+ Version: 0.0.44
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
@@ -22,11 +22,11 @@ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
22
22
  Classifier: Typing :: Typed
23
23
  Requires-Python: >=3.12
24
24
  Requires-Dist: celery[redis]<6,>=5.4
25
- Requires-Dist: redis<7,>=5
26
- Requires-Dist: simple-module-core==0.0.42
27
- Requires-Dist: simple-module-db==0.0.42
28
- Requires-Dist: simple-module-hosting==0.0.42
29
- Requires-Dist: simple-module-settings==0.0.42
25
+ Requires-Dist: redis<9,>=5
26
+ Requires-Dist: simple-module-core==0.0.44
27
+ Requires-Dist: simple-module-db==0.0.44
28
+ Requires-Dist: simple-module-hosting==0.0.44
29
+ Requires-Dist: simple-module-settings==0.0.44
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
 
@@ -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
@@ -40,7 +40,7 @@ from pydantic import Field, ValidationInfo, field_validator, model_validator
40
40
  from pydantic_core import PydanticCustomError
41
41
  from simple_module_core.settings_hydrate import RELATED_FIELDS_CTX
42
42
 
43
- from background_tasks.constants import (
43
+ from background_tasks.core.constants import (
44
44
  DEFAULT_OUTBOX_LEASE_SECONDS,
45
45
  DEFAULT_OUTBOX_MAX_ATTEMPTS,
46
46
  DEFAULT_OUTBOX_SWEEP_INTERVAL_SECONDS,
@@ -48,12 +48,12 @@ from background_tasks.constants import (
48
48
  ENV_PREFIX,
49
49
  max_outbox_handler_timeout,
50
50
  )
51
- from background_tasks.settings_celery import _CELERY_RESTART, CelerySettingsFields
52
- from background_tasks.settings_env_checks import (
51
+ from background_tasks.core.settings_celery import _CELERY_RESTART, CelerySettingsFields
52
+ from background_tasks.core.settings_env_checks import (
53
53
  forbid_localhost_broker_in_production,
54
54
  warn_on_legacy_redis_vars,
55
55
  )
56
- from background_tasks.tracking import TrackingMode
56
+ from background_tasks.core.tracking import TrackingMode
57
57
 
58
58
  __all__ = ["DEFAULT_RETENTION_DAYS", "ENV_PREFIX", "BackgroundTasksSettings"]
59
59
 
@@ -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,7 +11,7 @@ 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
 
@@ -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
+ """
@@ -15,7 +15,7 @@ Two delivery paths, picked per session:
15
15
  - **Any other session** — a worker's sync session, a CLI script's own
16
16
  ``async with session.begin()`` — has nobody to run ``on_commit`` callbacks,
17
17
  so the publish hangs off SQLAlchemy's ``after_commit`` event instead and is
18
- dropped when the outermost transaction ends without committing.
18
+ dropped when its savepoint or the outermost transaction rolls back.
19
19
 
20
20
  The broker id is reserved up front and returned, so the caller can write it
21
21
  onto its own row in the same transaction: the row names the task before the
@@ -31,6 +31,7 @@ from collections.abc import Callable, Sequence
31
31
  from typing import Any
32
32
 
33
33
  from simple_module_db import RequestSession, bind_current_tenant, mark_written
34
+ from simple_module_db.callbacks import open_savepoints
34
35
  from simple_module_db.transaction import SESSION_START_KEY
35
36
  from sqlalchemy import event
36
37
  from sqlalchemy.ext.asyncio import AsyncSession
@@ -108,7 +109,8 @@ def after_commit(
108
109
  db.on_commit(lambda: _run_all(batch))
109
110
  return
110
111
  sync = db.sync_session if isinstance(db, AsyncSession) else db
111
- sync.info.setdefault(_PENDING_KEY, []).extend(batch)
112
+ savepoints = open_savepoints(sync)
113
+ sync.info.setdefault(_PENDING_KEY, []).extend((savepoints, publish) for publish in batch)
112
114
  _hook(sync)
113
115
 
114
116
 
@@ -127,7 +129,14 @@ def _hook(session: Session) -> None:
127
129
  session.info[_HOOKED_KEY] = True
128
130
 
129
131
  def on_commit(sess: Session) -> None:
130
- _run_all(sess.info.pop(_PENDING_KEY, []))
132
+ if not sess.in_nested_transaction():
133
+ _run_all([publish for _, publish in sess.info.pop(_PENDING_KEY, [])])
134
+
135
+ def on_rollback(sess: Session, transaction: SessionTransaction) -> None:
136
+ if transaction.nested and _PENDING_KEY in sess.info:
137
+ sess.info[_PENDING_KEY] = [
138
+ entry for entry in sess.info[_PENDING_KEY] if transaction not in entry[0]
139
+ ]
131
140
 
132
141
  def on_end(sess: Session, transaction: SessionTransaction) -> None:
133
142
  # ``after_commit`` already took the batch on the commit path; anything
@@ -136,6 +145,7 @@ def _hook(session: Session) -> None:
136
145
  sess.info.pop(_PENDING_KEY, None)
137
146
 
138
147
  event.listen(session, "after_commit", on_commit)
148
+ event.listen(session, "after_soft_rollback", on_rollback)
139
149
  event.listen(session, "after_transaction_end", on_end)
140
150
 
141
151
 
@@ -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.
@@ -8,27 +8,29 @@ must not happen twice. The read paths have none of those questions.
8
8
 
9
9
  from __future__ import annotations
10
10
 
11
+ import json
11
12
  import logging
12
13
  import uuid
13
14
  from collections.abc import Callable, Sequence
14
15
  from typing import TYPE_CHECKING, Any
15
16
 
17
+ from kombu.utils.json import loads
16
18
  from simple_module_core.events import EventBus
17
19
  from simple_module_db import RequestSession, all_tenants, tenant_context
18
20
  from sqlalchemy import Select, func, select, update
19
21
  from sqlmodel import col
20
22
 
21
- from background_tasks._signal_support import now_utc
22
- from background_tasks.after_commit import after_commit
23
- from background_tasks.constants import RETRY_ALL_BATCH, SM_TRACKING_HEADER, TaskStatus
24
23
  from background_tasks.contracts.events import TaskRetried
25
24
  from background_tasks.contracts.schemas import RetryFailedResult
26
- 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
27
31
  from background_tasks.models import TaskExecution
28
- from background_tasks.sync_db import sync_session
29
- from background_tasks.task_resource import resource_headers
30
- from background_tasks.tenant_context import publish_as_owner
31
- 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
32
34
 
33
35
  if TYPE_CHECKING:
34
36
  from celery import Celery
@@ -41,7 +43,7 @@ def claim_query(conditions: Conditions, batch: int) -> Select[tuple[TaskExecutio
41
43
 
42
44
  ``FOR UPDATE SKIP LOCKED`` is what makes two simultaneous sweeps disjoint.
43
45
  The guard that is *supposed* to keep a row out of a second sweep —
44
- :func:`~background_tasks.filters.bulk_retry_conditions` excluding parents
46
+ :func:`~background_tasks.executions.filters.bulk_retry_conditions` excluding parents
45
47
  that already have a child — only starts working once the child row exists,
46
48
  and a concurrent sweep reads the same batch long before that. Locking the
47
49
  parents makes the second reader skip them instead of publishing the same
@@ -192,8 +194,8 @@ class RetryCoordinator:
192
194
  tenant_id = row.tenant_id
193
195
  owner_user_id = row.owner_user_id
194
196
  options: dict[str, Any] = {
195
- "args": list(row.args or []),
196
- "kwargs": dict(row.kwargs or {}),
197
+ "args": loads(json.dumps(row.args or [])),
198
+ "kwargs": loads(json.dumps(row.kwargs or {})),
197
199
  "queue": row.queue,
198
200
  "task_id": task_id,
199
201
  }
@@ -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
  *,