simple-module-background-tasks 0.0.49__tar.gz → 0.0.51__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.
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/PKG-INFO +5 -5
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/contracts/events.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/contracts/logs.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/core/_lifecycle.py +4 -4
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/core/constants.py +1 -11
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/core/db_settings.py +6 -4
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/core/health.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/core/invalidation.py +2 -2
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/core/invalidation_channel.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/core/settings.py +9 -10
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/core/settings_celery.py +2 -2
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/core/settings_env_checks.py +17 -25
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/core/sync_db.py +6 -6
- simple_module_background_tasks-0.0.51/background_tasks/executions/after_commit.py +291 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/executions/retry_service.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/executions/service.py +2 -2
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/executions/tenant_context.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/locales/de.json +147 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/locales/en.json +148 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/logs/service.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/logs/sink.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/models.py +3 -3
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/module.py +5 -5
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/outbox/clock.py +2 -2
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/outbox/dispatch.py +7 -3
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/outbox/service.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/outbox/sweep.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/outbox/transport.py +4 -4
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/outbox/worker.py +6 -6
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/pages/i18n.generated.ts +221 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/web/deps.py +3 -3
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/web/endpoints/api_admin.py +3 -3
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/web/endpoints/api_status.py +7 -7
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/web/endpoints/logs_api.py +3 -3
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/web/endpoints/logs_views.py +4 -4
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/web/endpoints/outbox_api.py +3 -3
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/web/endpoints/outbox_views.py +4 -4
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/web/endpoints/views.py +4 -4
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/worker/_signal_bus.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/worker/celery_app.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/worker/principals.py +6 -2
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/worker/runner.py +3 -3
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/worker/settings.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/package.json +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/pyproject.toml +5 -5
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/conftest.py +2 -2
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/core/health/test_background_tasks_redis_health.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/core/invalidation/test_background_tasks_invalidation.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/core/invalidation/test_background_tasks_invalidation_degraded.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/core/invalidation/test_background_tasks_invalidation_redis.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/core/invalidation/test_background_tasks_invalidation_warmup.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/core/invalidation/test_installation_channel.py +4 -4
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/core/invalidation/test_invalidation_bridge.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/core/settings/test_background_tasks_db_timeouts.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/core/settings/test_background_tasks_redis_url.py +69 -33
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/core/settings/test_background_tasks_settings.py +3 -3
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/executions/service/test_background_tasks_after_commit.py +2 -2
- simple_module_background_tasks-0.0.51/tests/executions/service/test_background_tasks_after_commit_bounded.py +115 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/executions/service/test_background_tasks_eager_bindings.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/executions/service/test_background_tasks_newest_first_status.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/executions/service/test_background_tasks_read_projection.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/executions/service/test_background_tasks_service.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/executions/service/test_background_tasks_tz_columns.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/outbox/admin/test_background_tasks_outbox_admin.py +2 -2
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/outbox/admin/test_background_tasks_outbox_tenancy.py +5 -3
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/outbox/delivery/test_background_tasks_delivery_context.py +2 -2
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/outbox/delivery/test_background_tasks_inprocess_sweep.py +3 -3
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/outbox/delivery/test_background_tasks_outbox_concurrency.py +4 -4
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/outbox/delivery/test_background_tasks_outbox_delivery.py +2 -2
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/outbox/delivery/test_background_tasks_outbox_eager_platform.py +3 -3
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/outbox/delivery/test_background_tasks_outbox_eager_serialization.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/outbox/delivery/test_background_tasks_outbox_fence_guard.py +5 -5
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/outbox/delivery/test_background_tasks_outbox_guard_savepoint.py +2 -2
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/outbox/delivery/test_background_tasks_outbox_publish_scope.py +3 -3
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/outbox/delivery/test_background_tasks_outbox_retry_policy.py +2 -2
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/outbox/delivery/test_background_tasks_outbox_swallowed_cancel.py +2 -2
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/outbox/delivery/test_background_tasks_outbox_worker_chain.py +5 -4
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/outbox/delivery/test_background_tasks_outbox_worker_task.py +2 -2
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/web/api/test_background_tasks_pagination_bounds.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/web/api/test_background_tasks_task_status_api.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/web/api/test_background_tasks_users_ordering.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/runner/test_background_tasks_principal_config.py +3 -3
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/runner/test_background_tasks_principals.py +2 -2
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/runner/test_background_tasks_routes_override_api.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/runner/test_background_tasks_runner_settings.py +5 -5
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/runner/test_background_tasks_worker_settings.py +2 -2
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/runner/test_runner_invalidation_identity.py +2 -2
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/signals/test_background_tasks_argument_json.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/signals/test_background_tasks_execution_bindings.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/signals/test_background_tasks_resource_status.py +4 -4
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/signals/test_background_tasks_task_progress.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/signals/test_background_tasks_task_progress_audit.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/signals/test_background_tasks_tracking_modes.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/signals/test_background_tasks_worker_audit.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/signals/test_background_tasks_worker_audit_bookkeeping.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/tenancy/test_background_tasks_custom_bases.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/tenancy/test_background_tasks_execution_tenancy.py +1 -1
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/tenancy/test_background_tasks_worker_tenancy_context.py +1 -1
- simple_module_background_tasks-0.0.49/background_tasks/executions/after_commit.py +0 -152
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/.gitignore +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/LICENSE +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/README.md +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/__init__.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/contracts/__init__.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/contracts/outbox.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/contracts/schemas.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/core/__init__.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/core/config_guards.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/core/services.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/core/settings_logs.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/core/tracking.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/executions/__init__.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/executions/filters.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/logs/__init__.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/logs/purge.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/outbox/__init__.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/outbox/claim.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/outbox/guard.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/outbox/loop.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/outbox/support.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/pages/Detail.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/pages/Index.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/pages/Logs.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/pages/Outbox.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/pages/Workers.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/pages/api.generated.ts +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/py.typed +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/tasks.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/DetailFacts.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/ExecutionRow.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/ExecutionsTable.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/LogLevelSelect.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/LogTable.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/LogsPanel.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/OutboxTable.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/PayloadCards.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/ProgressCard.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/RetryAllDialog.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/RetryConfirmDialog.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/RoutesTable.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/StatusPill.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/StatusStrip.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/TaskFilters.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/TasksEmpty.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/TracebackCard.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/WorkerCard.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/WorkerEmptyStates.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/components/WorkerHealthBanner.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/utils/constants.ts +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/utils/logs.ts +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/utils/outbox.ts +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/utils/retry.ts +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/ui/utils/worker-health.ts +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/web/__init__.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/web/endpoints/__init__.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/worker/__init__.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/worker/_signal_support.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/worker/fleet_state.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/worker/inspector.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/worker/log_context.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/worker/signals.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/worker/task_heartbeat.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/worker/task_resource.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/worker/task_routing.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/background_tasks/worker/tenant_celery.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/core/settings/test_background_tasks_beat_schedule.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/core/settings/test_background_tasks_config_guards.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/core/settings/test_background_tasks_settings_env.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/core/settings/test_background_tasks_startup_log_masking.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/core/sync_db/test_background_tasks_sync_db.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/core/sync_db/test_background_tasks_sync_db_fork.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/executions/retry/test_background_tasks_retry_failed_bulk.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/executions/retry/test_background_tasks_retry_failed_guards.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/executions/retry/test_background_tasks_retry_sweep_ordering.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/executions/service/test_background_tasks_index_has_executions.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/executions/service/test_background_tasks_list_item_payload.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/executions/service/test_background_tasks_order_index.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/executions/service/test_background_tasks_publish_validation.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/executions/service/test_background_tasks_retention_retries.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/executions/service/test_background_tasks_savepoint_publish.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/logs/purge/test_background_tasks_log_purge.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/logs/sink/test_background_tasks_log_context.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/logs/sink/test_background_tasks_log_sink.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/logs/sink/test_background_tasks_log_sink_loop.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/logs/sink/test_background_tasks_log_sink_nul.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/outbox/loop/test_background_tasks_outbox_loop_interrupt.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/outbox/loop/test_background_tasks_outbox_thread_loops.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/web/api/test_background_tasks_admin_api.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/web/api/test_background_tasks_detail_props.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/web/api/test_background_tasks_index_filters.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/web/api/test_background_tasks_log_api.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/web/api/test_background_tasks_page_clamp.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/inspector/test_background_tasks_index_worker_presence.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/inspector/test_background_tasks_worker_inspector.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/inspector/test_background_tasks_workers_endpoints.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/inspector/test_background_tasks_workers_uptime.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/runner/test_background_tasks_database_provider.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/runner/test_background_tasks_task_routing.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/signals/test_background_tasks_heartbeat.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/signals/test_background_tasks_quiet_sweep_unrecorded.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/signals/test_background_tasks_resource_transport.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/signals/test_background_tasks_result_json.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/signals/test_background_tasks_signal_tenant_stamp.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/signals/test_background_tasks_signals.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/signals/test_background_tasks_sweep_stuck.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/tenancy/test_background_tasks_tenant_context.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests/worker/tenancy/test_background_tasks_worker_tenancy.py +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests-js/background_tasks_DetailPage.test.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests-js/background_tasks_IndexPage.test.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests-js/background_tasks_LogsTab.test.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests-js/background_tasks_OutboxPage.test.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests-js/background_tasks_WorkerHealthBanner.test.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests-js/background_tasks_WorkersPage.test.tsx +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests-js/outbox.test.ts +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests-js/retry.test.ts +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests-js/stub-fetch.ts +0 -0
- {simple_module_background_tasks-0.0.49 → simple_module_background_tasks-0.0.51}/tests-js/task-formatters.test.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: simple_module_background_tasks
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.51
|
|
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.
|
|
27
|
-
Requires-Dist: simple-module-db==0.0.
|
|
28
|
-
Requires-Dist: simple-module-hosting==0.0.
|
|
29
|
-
Requires-Dist: simple-module-settings==0.0.
|
|
26
|
+
Requires-Dist: simple-module-core==0.0.51
|
|
27
|
+
Requires-Dist: simple-module-db==0.0.51
|
|
28
|
+
Requires-Dist: simple-module-hosting==0.0.51
|
|
29
|
+
Requires-Dist: simple-module-settings==0.0.51
|
|
30
30
|
Description-Content-Type: text/markdown
|
|
31
31
|
|
|
32
32
|
# simple_module_background_tasks
|
|
@@ -20,7 +20,7 @@ async def startup(app: FastAPI, module_name: str) -> None:
|
|
|
20
20
|
"""Build the Celery app, install signal handlers, hand-off to worker."""
|
|
21
21
|
import asyncio
|
|
22
22
|
|
|
23
|
-
from simple_module_hosting.log_sinks import redact
|
|
23
|
+
from simple_module_hosting.observability.log_sinks import redact
|
|
24
24
|
|
|
25
25
|
from background_tasks.core.db_settings import worker_database_options
|
|
26
26
|
from background_tasks.core.sync_db import configure_database, set_database_url
|
|
@@ -60,7 +60,7 @@ async def startup(app: FastAPI, module_name: str) -> None:
|
|
|
60
60
|
# Registered here, not in register_health_checks: the Celery app does
|
|
61
61
|
# not exist until this hook builds it, and the check must follow later
|
|
62
62
|
# settings changes rather than pinning the boot-time instance.
|
|
63
|
-
from simple_module_core.health import HealthCheck
|
|
63
|
+
from simple_module_core.web.health import HealthCheck
|
|
64
64
|
|
|
65
65
|
from background_tasks.core.health import CHECK_REDIS, build_redis_check
|
|
66
66
|
|
|
@@ -87,7 +87,7 @@ 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 simple_module_core.principals import PRINCIPALS_KEY
|
|
90
|
+
from simple_module_core.access.principals import PRINCIPALS_KEY
|
|
91
91
|
|
|
92
92
|
from background_tasks.core.constants import OutboxMode
|
|
93
93
|
from background_tasks.outbox.sweep import start_sweep
|
|
@@ -128,7 +128,7 @@ async def start_invalidation_transport(app: FastAPI) -> None:
|
|
|
128
128
|
documented cross-process limit as ``bind_event_bus`` above: a task that
|
|
129
129
|
invalidates a cache should do it through an API call or accept the TTL.
|
|
130
130
|
"""
|
|
131
|
-
from simple_module_hosting.installation import ensure_installation_id
|
|
131
|
+
from simple_module_hosting.config.installation import ensure_installation_id
|
|
132
132
|
|
|
133
133
|
from background_tasks.core.constants import DEFAULT_INVALIDATION_CHANNEL
|
|
134
134
|
from background_tasks.core.invalidation import RedisInvalidationTransport
|
|
@@ -10,8 +10,7 @@ from __future__ import annotations
|
|
|
10
10
|
|
|
11
11
|
from enum import StrEnum
|
|
12
12
|
|
|
13
|
-
from simple_module_core.
|
|
14
|
-
from simple_module_core.permissions import PermissionCatalogue
|
|
13
|
+
from simple_module_core.access.permissions import PermissionCatalogue
|
|
15
14
|
|
|
16
15
|
# ── Module identity ─────────────────────────────────────────────
|
|
17
16
|
MODULE_NAME = "background_tasks"
|
|
@@ -45,15 +44,6 @@ class Permissions(
|
|
|
45
44
|
MANAGE = "background_tasks.manage"
|
|
46
45
|
|
|
47
46
|
|
|
48
|
-
deprecate(
|
|
49
|
-
"background_tasks PERM_* constants",
|
|
50
|
-
remove_in="0.0.50",
|
|
51
|
-
use="background_tasks.core.constants.Permissions",
|
|
52
|
-
)
|
|
53
|
-
PERM_VIEW = Permissions.VIEW
|
|
54
|
-
PERM_MANAGE = Permissions.MANAGE
|
|
55
|
-
|
|
56
|
-
|
|
57
47
|
# ── Routes ──────────────────────────────────────────────────────
|
|
58
48
|
API_PREFIX = "/api/background_tasks"
|
|
59
49
|
VIEW_PREFIX = "/admin/background-tasks"
|
|
@@ -11,10 +11,12 @@ _RESTART = {"requires_restart": True, "group": "Database"}
|
|
|
11
11
|
class WorkerDatabaseSettings(BaseSettings):
|
|
12
12
|
"""Inherited by BackgroundTasksSettings with its SM_BG_TASKS_ env prefix."""
|
|
13
13
|
|
|
14
|
-
db_pool_size: int = Field(default=2, ge=1, json_schema_extra=_RESTART)
|
|
15
|
-
db_max_overflow: int = Field(default=3, ge=0, json_schema_extra=_RESTART)
|
|
16
|
-
db_recycle: int = Field(default=1800, ge=0, json_schema_extra=_RESTART)
|
|
17
|
-
db_statement_timeout_ms: int | None = Field(
|
|
14
|
+
db_pool_size: int = Field(default=2, ge=1, le=1000, json_schema_extra=_RESTART)
|
|
15
|
+
db_max_overflow: int = Field(default=3, ge=0, le=1000, json_schema_extra=_RESTART)
|
|
16
|
+
db_recycle: int = Field(default=1800, ge=0, le=2_147_483_647, json_schema_extra=_RESTART)
|
|
17
|
+
db_statement_timeout_ms: int | None = Field(
|
|
18
|
+
default=None, ge=0, le=2_147_483_647, json_schema_extra=_RESTART
|
|
19
|
+
)
|
|
18
20
|
|
|
19
21
|
|
|
20
22
|
def worker_database_options(host: Any, worker: WorkerDatabaseSettings) -> dict[str, int]:
|
|
@@ -17,7 +17,7 @@ from __future__ import annotations
|
|
|
17
17
|
import asyncio
|
|
18
18
|
|
|
19
19
|
from fastapi import FastAPI
|
|
20
|
-
from simple_module_core.health import HealthCheckResult, HealthStatus
|
|
20
|
+
from simple_module_core.web.health import HealthCheckResult, HealthStatus
|
|
21
21
|
|
|
22
22
|
CHECK_REDIS = "background_tasks.redis"
|
|
23
23
|
|
|
@@ -23,7 +23,7 @@ import logging
|
|
|
23
23
|
from typing import TYPE_CHECKING
|
|
24
24
|
|
|
25
25
|
if TYPE_CHECKING:
|
|
26
|
-
from simple_module_core.invalidation import InvalidationBus
|
|
26
|
+
from simple_module_core.eventing.invalidation import InvalidationBus
|
|
27
27
|
|
|
28
28
|
logger = logging.getLogger(__name__)
|
|
29
29
|
|
|
@@ -92,7 +92,7 @@ a round trip on an open socket, not a connect.
|
|
|
92
92
|
class RedisInvalidationTransport:
|
|
93
93
|
"""Publishes and listens on a channel plus an optional rolling-upgrade bridge.
|
|
94
94
|
|
|
95
|
-
Satisfies ``simple_module_core.invalidation.InvalidationTransport``
|
|
95
|
+
Satisfies ``simple_module_core.eventing.invalidation.InvalidationTransport``
|
|
96
96
|
structurally — no import of the Protocol at runtime, so this file costs
|
|
97
97
|
nothing when the bus is unused.
|
|
98
98
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Default installation channel and the temporary rolling-upgrade bridge."""
|
|
2
2
|
|
|
3
|
-
from simple_module_core.deprecation import deprecate
|
|
3
|
+
from simple_module_core.runtime.deprecation import deprecate
|
|
4
4
|
|
|
5
5
|
from background_tasks.core.constants import DEFAULT_INVALIDATION_CHANNEL
|
|
6
6
|
|
|
@@ -13,13 +13,12 @@ never sees ``app.state``) has no other source at all. Like every env var it
|
|
|
13
13
|
beats a stored value (env → DB → default): ``env_seeded_fields`` reports both
|
|
14
14
|
fields to the hydrator, since ``SM_REDIS_URL`` is read by their default
|
|
15
15
|
factories where pydantic's env source cannot see it. With it unset, the two
|
|
16
|
-
fields keep separate DB overrides
|
|
17
|
-
backend on different Redis databases.
|
|
16
|
+
fields keep separate DB overrides.
|
|
18
17
|
|
|
19
|
-
``SM_BG_TASKS_BROKER_URL`` and ``SM_BG_TASKS_RESULT_BACKEND``
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
``SM_BG_TASKS_BROKER_URL`` and ``SM_BG_TASKS_RESULT_BACKEND`` are supported
|
|
19
|
+
per-field overrides for separate Redis databases or other transports (#1214).
|
|
20
|
+
They take precedence over ``SM_REDIS_URL``. An INFO message suggests removing
|
|
21
|
+
an override only when it equals the configured ``SM_REDIS_URL``. Being real
|
|
23
22
|
env reads, they also beat a stored value (env → DB → default, GH #486). They
|
|
24
23
|
are answered by pydantic's own env source now that ``env_prefix`` is set
|
|
25
24
|
(GH #283), which is also what stops every other field being readable from its
|
|
@@ -40,7 +39,7 @@ from typing import Literal
|
|
|
40
39
|
|
|
41
40
|
from pydantic import Field, ValidationInfo, field_validator, model_validator
|
|
42
41
|
from pydantic_core import PydanticCustomError
|
|
43
|
-
from simple_module_core.settings_hydrate import RELATED_FIELDS_CTX
|
|
42
|
+
from simple_module_core.settings.settings_hydrate import RELATED_FIELDS_CTX
|
|
44
43
|
|
|
45
44
|
from background_tasks.core.constants import (
|
|
46
45
|
DEFAULT_OUTBOX_LEASE_SECONDS,
|
|
@@ -53,7 +52,7 @@ from background_tasks.core.constants import (
|
|
|
53
52
|
from background_tasks.core.settings_celery import _CELERY_RESTART, CelerySettingsFields
|
|
54
53
|
from background_tasks.core.settings_env_checks import (
|
|
55
54
|
forbid_localhost_broker_in_production,
|
|
56
|
-
|
|
55
|
+
warn_on_redundant_redis_vars,
|
|
57
56
|
)
|
|
58
57
|
from background_tasks.core.tracking import TrackingMode
|
|
59
58
|
|
|
@@ -171,7 +170,7 @@ class BackgroundTasksSettings(CelerySettingsFields):
|
|
|
171
170
|
|
|
172
171
|
@model_validator(mode="after")
|
|
173
172
|
def _check_broker_env(self) -> BackgroundTasksSettings:
|
|
174
|
-
"""
|
|
175
|
-
|
|
173
|
+
"""Redundant-override hints and the production localhost-broker refusal."""
|
|
174
|
+
warn_on_redundant_redis_vars(self.broker_url, self.result_backend)
|
|
176
175
|
forbid_localhost_broker_in_production(self.broker_url, self.result_backend)
|
|
177
176
|
return self
|
|
@@ -13,7 +13,7 @@ from typing import Any
|
|
|
13
13
|
from pydantic import Field, ValidationInfo, field_validator
|
|
14
14
|
from pydantic_core import PydanticCustomError
|
|
15
15
|
from pydantic_settings import SettingsConfigDict
|
|
16
|
-
from simple_module_core.settings_hydrate import RELATED_FIELDS_CTX
|
|
16
|
+
from simple_module_core.settings.settings_hydrate import RELATED_FIELDS_CTX
|
|
17
17
|
|
|
18
18
|
from background_tasks.core.config_guards import parse_task_routes
|
|
19
19
|
from background_tasks.core.constants import (
|
|
@@ -41,7 +41,7 @@ def _redis_from_env(default: str) -> str:
|
|
|
41
41
|
``env_prefix`` means pydantic's env source has already answered
|
|
42
42
|
``SM_BG_TASKS_BROKER_URL`` / ``SM_BG_TASKS_RESULT_BACKEND`` by the time a
|
|
43
43
|
default is needed, so this factory is only the ``SM_REDIS_URL`` half — the
|
|
44
|
-
|
|
44
|
+
per-field overrides take precedence through that source instead."""
|
|
45
45
|
return os.environ.get(ENV_REDIS_URL) or default
|
|
46
46
|
|
|
47
47
|
|
|
@@ -9,7 +9,7 @@ from __future__ import annotations
|
|
|
9
9
|
import logging
|
|
10
10
|
import os
|
|
11
11
|
|
|
12
|
-
from simple_module_core.environments import NON_PROD_ENVIRONMENTS
|
|
12
|
+
from simple_module_core.settings.environments import NON_PROD_ENVIRONMENTS
|
|
13
13
|
|
|
14
14
|
from background_tasks.core.constants import ENV_PREFIX, ENV_REDIS_URL
|
|
15
15
|
|
|
@@ -22,32 +22,24 @@ logger = logging.getLogger("background_tasks.settings")
|
|
|
22
22
|
_REDIS_SCHEMES = frozenset({"redis", "rediss"})
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
def
|
|
26
|
-
"""
|
|
25
|
+
def warn_on_redundant_redis_vars(broker_url: str, result_backend: str) -> None:
|
|
26
|
+
"""Suggest removing only overrides already supplied by ``SM_REDIS_URL``.
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
than in the default factory because ``env_prefix`` means the env source
|
|
32
|
-
answers these names before any default is consulted, so the factory never
|
|
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
|
+
Per-field overrides support separate Redis DBs and non-Redis transports
|
|
29
|
+
(#1214). Check the effective value too: explicit constructor arguments can
|
|
30
|
+
supersede the environment. Never log URLs, which may contain credentials.
|
|
39
31
|
"""
|
|
40
|
-
|
|
32
|
+
redis_url = os.environ.get(ENV_REDIS_URL)
|
|
33
|
+
if not redis_url or redis_url.partition("://")[0].lower() not in _REDIS_SCHEMES:
|
|
34
|
+
return
|
|
35
|
+
for value, env_var in (
|
|
41
36
|
(broker_url, f"{ENV_PREFIX}BROKER_URL"),
|
|
42
37
|
(result_backend, f"{ENV_PREFIX}RESULT_BACKEND"),
|
|
43
38
|
):
|
|
44
|
-
if os.environ.get(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"%s is deprecated; use %s instead (one URL seeds both the "
|
|
49
|
-
"broker and the result backend).",
|
|
50
|
-
legacy_var,
|
|
39
|
+
if os.environ.get(env_var) == value == redis_url:
|
|
40
|
+
logger.info(
|
|
41
|
+
"%s is redundant with %s and can be removed.",
|
|
42
|
+
env_var,
|
|
51
43
|
ENV_REDIS_URL,
|
|
52
44
|
)
|
|
53
45
|
|
|
@@ -74,8 +66,8 @@ def forbid_localhost_broker_in_production(broker_url: str, result_backend: str)
|
|
|
74
66
|
f"{names} must not point at localhost when SM_ENVIRONMENT={env!r}. "
|
|
75
67
|
f"Set {ENV_REDIS_URL} on the container to the Redis service host "
|
|
76
68
|
"(e.g. redis://redis:6379/0) — one URL seeds both the broker and "
|
|
77
|
-
f"the result backend. ({env_names}
|
|
78
|
-
"
|
|
79
|
-
"
|
|
69
|
+
f"the result backend. ({env_names} override it per field for "
|
|
70
|
+
"separate Redis databases or other transports.) "
|
|
71
|
+
"Environment variables are read before the "
|
|
80
72
|
"DB-backed settings exist, so one is what satisfies this at boot."
|
|
81
73
|
)
|
|
@@ -20,11 +20,11 @@ from contextlib import contextmanager
|
|
|
20
20
|
|
|
21
21
|
from celery.signals import worker_process_init
|
|
22
22
|
from simple_module_db import DEFAULT_TENANT_ID
|
|
23
|
-
from simple_module_db.audit_sinks import discover_audit_callback
|
|
24
|
-
from simple_module_db.engine_options import connect_args
|
|
25
|
-
from simple_module_db.
|
|
26
|
-
from simple_module_db.
|
|
27
|
-
from simple_module_db.query_filter import EngineTenancy, bind_engine_policy
|
|
23
|
+
from simple_module_db.auditing.audit_sinks import discover_audit_callback
|
|
24
|
+
from simple_module_db.engine.engine_options import connect_args
|
|
25
|
+
from simple_module_db.engine.provider import DatabaseProvider, detect_provider
|
|
26
|
+
from simple_module_db.models.listeners import attach_session_listeners
|
|
27
|
+
from simple_module_db.scoping.query_filter import EngineTenancy, bind_engine_policy
|
|
28
28
|
from sqlalchemy import create_engine
|
|
29
29
|
from sqlalchemy.engine import Engine
|
|
30
30
|
from sqlalchemy.orm import Session, sessionmaker
|
|
@@ -227,7 +227,7 @@ def _dispose_inherited_engine(**_: object) -> None:
|
|
|
227
227
|
@worker_process_init.connect
|
|
228
228
|
def _init_sentry(**_: object) -> None:
|
|
229
229
|
"""Start Sentry in each prefork child (no-op without ``SM_SENTRY_DSN``)."""
|
|
230
|
-
from simple_module_hosting.sentry import PROCESS_WORKER, init_sentry
|
|
230
|
+
from simple_module_hosting.observability.sentry import PROCESS_WORKER, init_sentry
|
|
231
231
|
|
|
232
232
|
init_sentry(PROCESS_WORKER)
|
|
233
233
|
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"""Publish to the broker only once the transaction that justifies it commits.
|
|
2
|
+
|
|
3
|
+
A task enqueued inside a transaction races that transaction: the worker can
|
|
4
|
+
pick the message up before the row it refers to is visible (eager mode runs
|
|
5
|
+
it *inside* ``send_task``), and if the commit then fails the task is already
|
|
6
|
+
queued against nothing. Both are fixed the same way — hold the publish until
|
|
7
|
+
the commit has landed, and drop it if the transaction rolls back (GH #452).
|
|
8
|
+
|
|
9
|
+
Two delivery paths, picked per session:
|
|
10
|
+
|
|
11
|
+
- **A request's session** (``get_db``) — the publish goes through
|
|
12
|
+
:meth:`~simple_module_db.RequestSession.on_commit`, which the framework runs
|
|
13
|
+
after the request's commit and before the response is sent, and discards on
|
|
14
|
+
rollback or commit failure.
|
|
15
|
+
- **Any other session** — a worker's sync session, a CLI script's own
|
|
16
|
+
``async with session.begin()`` — has nobody to run ``on_commit`` callbacks,
|
|
17
|
+
so the publish hangs off SQLAlchemy's ``after_commit`` event instead and is
|
|
18
|
+
dropped when its savepoint or the outermost transaction rolls back.
|
|
19
|
+
|
|
20
|
+
The broker id is reserved up front and returned, so the caller can write it
|
|
21
|
+
onto its own row in the same transaction: the row names the task before the
|
|
22
|
+
task exists, never the other way round.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
|
|
27
|
+
import asyncio
|
|
28
|
+
import logging
|
|
29
|
+
import threading
|
|
30
|
+
import uuid
|
|
31
|
+
from collections.abc import Callable, Sequence
|
|
32
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
33
|
+
from typing import Any
|
|
34
|
+
|
|
35
|
+
from simple_module_db import RequestSession, bind_current_tenant, mark_written
|
|
36
|
+
from simple_module_db.engine.callbacks import open_savepoints
|
|
37
|
+
from simple_module_db.engine.transaction import SESSION_START_KEY
|
|
38
|
+
from sqlalchemy import event
|
|
39
|
+
from sqlalchemy.ext.asyncio import AsyncSession
|
|
40
|
+
from sqlalchemy.orm import Session, SessionTransaction
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class _LazyCurrentApp:
|
|
44
|
+
"""``celery.current_app``, imported on first use so importing this module stays light."""
|
|
45
|
+
|
|
46
|
+
def __getattr__(self, name: str) -> Any:
|
|
47
|
+
from celery import current_app as _current_app
|
|
48
|
+
|
|
49
|
+
return getattr(_current_app, name)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
current_app: Any = _LazyCurrentApp()
|
|
53
|
+
|
|
54
|
+
logger = logging.getLogger(__name__)
|
|
55
|
+
|
|
56
|
+
type Publish = Callable[[], object]
|
|
57
|
+
|
|
58
|
+
_PENDING_KEY = "background_tasks_after_commit"
|
|
59
|
+
_HOOKED_KEY = "background_tasks_after_commit_hooked"
|
|
60
|
+
# Upper bound for best-effort broker publish after commit (#1288).
|
|
61
|
+
PUBLISH_TIMEOUT_SECONDS = 2.0
|
|
62
|
+
_PUBLISH_WORKERS = 4
|
|
63
|
+
_PUBLISH_MAX_INFLIGHT = 8
|
|
64
|
+
_publish_executor = ThreadPoolExecutor(
|
|
65
|
+
max_workers=_PUBLISH_WORKERS, thread_name_prefix="celery-publish"
|
|
66
|
+
)
|
|
67
|
+
_publish_slots = threading.Semaphore(_PUBLISH_MAX_INFLIGHT)
|
|
68
|
+
_bg_publish_tasks: set[asyncio.Task[None]] = set()
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _celery_app_for(task: Any) -> Any:
|
|
72
|
+
return current_app if isinstance(task, str) else getattr(task, "app", None)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _is_non_eager_celery(celery_app: Any) -> bool:
|
|
76
|
+
"""True for a real Celery app publishing to a broker (not eager / mock)."""
|
|
77
|
+
conf = getattr(celery_app, "conf", None)
|
|
78
|
+
eager = getattr(conf, "task_always_eager", None)
|
|
79
|
+
return (
|
|
80
|
+
isinstance(eager, bool)
|
|
81
|
+
and not eager
|
|
82
|
+
and callable(getattr(celery_app, "connection_for_write", None))
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _bounded_transport_options(celery_app: Any, timeout: float) -> dict[str, Any]:
|
|
87
|
+
conf = getattr(celery_app, "conf", None)
|
|
88
|
+
existing = getattr(conf, "broker_transport_options", None)
|
|
89
|
+
opts: dict[str, Any] = dict(existing) if isinstance(existing, dict) else {}
|
|
90
|
+
opts["max_retries"] = 0
|
|
91
|
+
broker_url = getattr(conf, "broker_url", None) or ""
|
|
92
|
+
if isinstance(broker_url, str) and broker_url.startswith(("redis://", "rediss://")):
|
|
93
|
+
opts["socket_connect_timeout"] = min(
|
|
94
|
+
float(opts.get("socket_connect_timeout", timeout)), timeout
|
|
95
|
+
)
|
|
96
|
+
opts["socket_timeout"] = min(float(opts.get("socket_timeout", timeout)), timeout)
|
|
97
|
+
return opts
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _publish_bounded(
|
|
101
|
+
celery_app: Any,
|
|
102
|
+
task: Any,
|
|
103
|
+
args: tuple[Any, ...],
|
|
104
|
+
kwargs: dict[str, Any],
|
|
105
|
+
task_id: str,
|
|
106
|
+
timeout: float,
|
|
107
|
+
) -> None:
|
|
108
|
+
opts = _bounded_transport_options(celery_app, timeout)
|
|
109
|
+
with celery_app.connection_for_write(connect_timeout=timeout, transport_options=opts) as conn:
|
|
110
|
+
if isinstance(task, str):
|
|
111
|
+
celery_app.send_task(
|
|
112
|
+
task,
|
|
113
|
+
args=list(args),
|
|
114
|
+
kwargs=kwargs,
|
|
115
|
+
task_id=task_id,
|
|
116
|
+
connection=conn,
|
|
117
|
+
retry=False,
|
|
118
|
+
ignore_result=True,
|
|
119
|
+
)
|
|
120
|
+
else:
|
|
121
|
+
task.apply_async(
|
|
122
|
+
args=args,
|
|
123
|
+
kwargs=kwargs,
|
|
124
|
+
task_id=task_id,
|
|
125
|
+
connection=conn,
|
|
126
|
+
retry=False,
|
|
127
|
+
ignore_result=True,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def _run_batch_guarded(batch: Sequence[Publish]) -> None:
|
|
132
|
+
try:
|
|
133
|
+
_run_all(batch)
|
|
134
|
+
finally:
|
|
135
|
+
_publish_slots.release()
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
async def _offload_batch(batch: Sequence[Publish], timeout: float | None) -> None:
|
|
139
|
+
"""Run ``batch`` on the dedicated publisher pool with bounded admission."""
|
|
140
|
+
if not _publish_slots.acquire(blocking=False):
|
|
141
|
+
logger.warning("background_tasks.after_commit.publish_saturated count=%d", len(batch))
|
|
142
|
+
return
|
|
143
|
+
loop = asyncio.get_running_loop()
|
|
144
|
+
try:
|
|
145
|
+
fut = loop.run_in_executor(_publish_executor, _run_batch_guarded, batch)
|
|
146
|
+
except Exception:
|
|
147
|
+
_publish_slots.release()
|
|
148
|
+
raise
|
|
149
|
+
if timeout is None:
|
|
150
|
+
await fut
|
|
151
|
+
return
|
|
152
|
+
try:
|
|
153
|
+
await asyncio.wait_for(asyncio.shield(fut), timeout=timeout)
|
|
154
|
+
except TimeoutError:
|
|
155
|
+
logger.warning(
|
|
156
|
+
"background_tasks.after_commit.publish_timed_out timeout=%s count=%d",
|
|
157
|
+
timeout,
|
|
158
|
+
len(batch),
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def enqueue_after_commit(db: AsyncSession | Session, task: Any, *args: Any, **kwargs: Any) -> str:
|
|
163
|
+
"""Send *task* once *db*'s transaction commits; never if it rolls back.
|
|
164
|
+
|
|
165
|
+
Delivery is at-most-once: publish intent exists only in memory. Broker
|
|
166
|
+
failure after commit is logged without retry; a process exit between commit
|
|
167
|
+
and publish also loses the job. For must-run work use the event bus's
|
|
168
|
+
``publish_durable(event, db)`` transactional outbox with a durable handler.
|
|
169
|
+
|
|
170
|
+
*task* is a Celery task (``send_receipt``), a signature
|
|
171
|
+
(``send_receipt.s().set(queue="mail")``, for routing options), or a
|
|
172
|
+
registered task name. ``*args`` / ``**kwargs`` are the task's own
|
|
173
|
+
arguments. Returns the Celery task id the message will carry.
|
|
174
|
+
|
|
175
|
+
Publishes as the tenant bound *now*, so a task enqueued in a request runs
|
|
176
|
+
for that request's tenant even when the commit happens elsewhere.
|
|
177
|
+
"""
|
|
178
|
+
task_id = str(uuid.uuid4())
|
|
179
|
+
celery_app = _celery_app_for(task)
|
|
180
|
+
non_eager = _is_non_eager_celery(celery_app)
|
|
181
|
+
|
|
182
|
+
def publish() -> None:
|
|
183
|
+
if non_eager:
|
|
184
|
+
_publish_bounded(celery_app, task, args, kwargs, task_id, PUBLISH_TIMEOUT_SECONDS)
|
|
185
|
+
elif isinstance(task, str):
|
|
186
|
+
current_app.send_task(task, args=list(args), kwargs=kwargs, task_id=task_id)
|
|
187
|
+
else:
|
|
188
|
+
task.apply_async(args=args, kwargs=kwargs, task_id=task_id)
|
|
189
|
+
|
|
190
|
+
after_commit(
|
|
191
|
+
db,
|
|
192
|
+
[bind_current_tenant(publish)],
|
|
193
|
+
offload=non_eager,
|
|
194
|
+
timeout=PUBLISH_TIMEOUT_SECONDS if non_eager else None,
|
|
195
|
+
)
|
|
196
|
+
return task_id
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def after_commit(
|
|
200
|
+
db: AsyncSession | Session,
|
|
201
|
+
publishes: Sequence[Publish],
|
|
202
|
+
*,
|
|
203
|
+
offload: bool = False,
|
|
204
|
+
timeout: float | None = None,
|
|
205
|
+
) -> None:
|
|
206
|
+
"""Run each of *publishes* after *db* commits, in order. Internal.
|
|
207
|
+
|
|
208
|
+
*offload* sends the batch to a dedicated publisher thread pool: kombu
|
|
209
|
+
publishes block, and running them on the event loop stalls every other
|
|
210
|
+
request. Left off for eager publishes so Celery's eager mode — which runs
|
|
211
|
+
the task body inside the publish — stays on the loop's thread. When
|
|
212
|
+
*timeout* is set alongside *offload*, the caller waits at most *timeout*
|
|
213
|
+
seconds before logging a warning and returning. One failed publish is
|
|
214
|
+
logged and does not stop the rest: the rows are already committed.
|
|
215
|
+
"""
|
|
216
|
+
batch = list(publishes)
|
|
217
|
+
if isinstance(db, RequestSession) and SESSION_START_KEY in db.info:
|
|
218
|
+
# A request that wrote nothing else is rolled back and its ``on_commit``
|
|
219
|
+
# callbacks discarded, which would drop this publish silently. Queueing a
|
|
220
|
+
# task is itself work that must survive to the commit.
|
|
221
|
+
mark_written(db)
|
|
222
|
+
if offload:
|
|
223
|
+
db.on_commit(lambda: _offload_batch(batch, timeout))
|
|
224
|
+
else:
|
|
225
|
+
db.on_commit(lambda: _run_all(batch))
|
|
226
|
+
return
|
|
227
|
+
sync = db.sync_session if isinstance(db, AsyncSession) else db
|
|
228
|
+
savepoints = open_savepoints(sync)
|
|
229
|
+
sync.info.setdefault(_PENDING_KEY, []).extend(
|
|
230
|
+
(savepoints, publish, offload, timeout) for publish in batch
|
|
231
|
+
)
|
|
232
|
+
_hook(sync)
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def _run_all(batch: Sequence[Publish]) -> None:
|
|
236
|
+
for publish in batch:
|
|
237
|
+
try:
|
|
238
|
+
publish()
|
|
239
|
+
except Exception:
|
|
240
|
+
logger.warning("background_tasks.after_commit.publish_failed", exc_info=True)
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def _dispatch_unmanaged(entries: Sequence[tuple[Any, Publish, bool, float | None]]) -> None:
|
|
244
|
+
inline = [pub for _, pub, offload, _ in entries if not offload]
|
|
245
|
+
offloaded = [(pub, timeout) for _, pub, offload, timeout in entries if offload]
|
|
246
|
+
if inline:
|
|
247
|
+
_run_all(inline)
|
|
248
|
+
if not offloaded:
|
|
249
|
+
return
|
|
250
|
+
try:
|
|
251
|
+
loop = asyncio.get_running_loop()
|
|
252
|
+
except RuntimeError:
|
|
253
|
+
_run_all([pub for pub, _ in offloaded])
|
|
254
|
+
return
|
|
255
|
+
timeouts = [t for _, t in offloaded if t is not None]
|
|
256
|
+
bound = min(timeouts) if timeouts else None
|
|
257
|
+
task = loop.create_task( # noqa: RUF006 — tracked in _bg_publish_tasks
|
|
258
|
+
_offload_batch([pub for pub, _ in offloaded], bound)
|
|
259
|
+
)
|
|
260
|
+
_bg_publish_tasks.add(task)
|
|
261
|
+
task.add_done_callback(_bg_publish_tasks.discard)
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def _hook(session: Session) -> None:
|
|
265
|
+
"""Attach the commit/rollback listeners to *session* once."""
|
|
266
|
+
if session.info.get(_HOOKED_KEY):
|
|
267
|
+
return
|
|
268
|
+
session.info[_HOOKED_KEY] = True
|
|
269
|
+
|
|
270
|
+
def on_commit(sess: Session) -> None:
|
|
271
|
+
if not sess.in_nested_transaction():
|
|
272
|
+
_dispatch_unmanaged(sess.info.pop(_PENDING_KEY, []))
|
|
273
|
+
|
|
274
|
+
def on_rollback(sess: Session, transaction: SessionTransaction) -> None:
|
|
275
|
+
if transaction.nested and _PENDING_KEY in sess.info:
|
|
276
|
+
sess.info[_PENDING_KEY] = [
|
|
277
|
+
entry for entry in sess.info[_PENDING_KEY] if transaction not in entry[0]
|
|
278
|
+
]
|
|
279
|
+
|
|
280
|
+
def on_end(sess: Session, transaction: SessionTransaction) -> None:
|
|
281
|
+
# ``after_commit`` already took the batch on the commit path; anything
|
|
282
|
+
# still queued when the outermost transaction ends was rolled back.
|
|
283
|
+
if transaction.parent is None:
|
|
284
|
+
sess.info.pop(_PENDING_KEY, None)
|
|
285
|
+
|
|
286
|
+
event.listen(session, "after_commit", on_commit)
|
|
287
|
+
event.listen(session, "after_soft_rollback", on_rollback)
|
|
288
|
+
event.listen(session, "after_transaction_end", on_end)
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
__all__ = ["enqueue_after_commit"]
|
|
@@ -15,7 +15,7 @@ from collections.abc import Callable, Sequence
|
|
|
15
15
|
from typing import TYPE_CHECKING, Any
|
|
16
16
|
|
|
17
17
|
from kombu.utils.json import loads
|
|
18
|
-
from simple_module_core.events import EventBus
|
|
18
|
+
from simple_module_core.eventing.events import EventBus
|
|
19
19
|
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
|
|
@@ -7,9 +7,9 @@ from datetime import UTC, datetime, timedelta
|
|
|
7
7
|
from typing import TYPE_CHECKING
|
|
8
8
|
|
|
9
9
|
from fastapi import HTTPException, status
|
|
10
|
-
from simple_module_core.events import EventBus
|
|
10
|
+
from simple_module_core.eventing.events import EventBus
|
|
11
11
|
from simple_module_db import RequestSession
|
|
12
|
-
from simple_module_db.pagination import total_pages
|
|
12
|
+
from simple_module_db.queries.pagination import total_pages
|
|
13
13
|
from sqlalchemy import func, select
|
|
14
14
|
|
|
15
15
|
from background_tasks.contracts.schemas import (
|
|
@@ -18,7 +18,7 @@ from contextvars import ContextVar, Token
|
|
|
18
18
|
from typing import Any
|
|
19
19
|
|
|
20
20
|
from simple_module_db import TenantIsolationError, current_tenant_id, is_valid_tenant_id
|
|
21
|
-
from simple_module_db.listeners import current_user_id
|
|
21
|
+
from simple_module_db.models.listeners import current_user_id
|
|
22
22
|
|
|
23
23
|
from background_tasks.core.constants import OWNER_ID_MAX_LENGTH
|
|
24
24
|
|