procrastinate 3.7.2__tar.gz → 3.8.0__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.
- {procrastinate-3.7.2 → procrastinate-3.8.0}/PKG-INFO +1 -1
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/blueprints.py +4 -1
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/connector.py +24 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/sqlalchemy/psycopg2_connector.py +13 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/jobs.py +15 -5
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/manager.py +40 -12
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/psycopg_connector.py +20 -2
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/schema.sql +17 -1
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sync_psycopg_connector.py +19 -3
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/tasks.py +12 -1
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/testing.py +11 -1
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/worker.py +3 -3
- {procrastinate-3.7.2 → procrastinate-3.8.0}/.gitignore +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/LICENSE.md +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/README.md +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/__init__.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/__main__.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/app.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/builtin_tasks.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/cli.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/README.md +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/__init__.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/aiopg/__init__.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/aiopg/aiopg_connector.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/README.md +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/__init__.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/admin.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/apps.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/django_connector.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/exceptions.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/healthchecks.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/management/__init__.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/management/commands/__init__.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/management/commands/procrastinate.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0001_initial.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0002_drop_started_at_column.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0003_drop_started_at_column.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0004_drop_procrastinate_version_table.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0005_fix_procrastinate_fetch_job.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0006_fix_trigger_status_events_insert.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0007_add_queueing_lock_column.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0008_close_fetch_job_race_condition.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0009_add_defer_job_function.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0010_add_procrastinate_periodic_defers.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0011_add_foreign_key_index.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0012_add_locks_to_periodic_defer.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0013_fix_procrastinate_defer_periodic_job.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0014_add_finish_job_and_retry_job_functions.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0015_add_trigger_on_job_deletion.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0016_delete_finished_jobs.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0017_add_checks_to_finish_job.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0018_add_checks_to_retry_job.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0019_fix_finish_job_compat_issue.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0020_add_index_on_procrastinate_jobs.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0021_add_kwargs_to_defer_periodic_job.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0022_null_locks_excluded.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0023_remove_old_finish_job_function.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0024_job_id_bigint.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0025_add_models.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0026_add_job_priority.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0027_add_periodic_job_priority.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0028_add_cancel_states.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0029_add_additional_params_to_retry_job.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0030_alter_procrastinateevent_options.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0031_add_indexes_for_fetch_job.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0032_pre_cancel_notification.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0033_post_cancel_notification.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0034_pre_add_heartbeat.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0035_post_add_heartbeat.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0036_add_worker_model.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0037_pre_batch_defer_jobs.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0038_post_batch_defer_jobs.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0039_pre_priority_lock_fetch_job.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0040_pre_retry_failed_job.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0041_post_retry_failed_job.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/__init__.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations_utils.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/models.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/procrastinate_app.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/settings.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/templates/procrastinate/admin/summary.html +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/utils.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/psycopg2/__init__.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/psycopg2/psycopg2_connector.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/sphinx/__init__.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/sqlalchemy/README.md +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/sqlalchemy/__init__.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/exceptions.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/job_context.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/metadata.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/periodic.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/py.typed +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/retry.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/schema.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/shell.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/signals.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/__init__.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/future_migrations/02.00.00_01_drop_old_procrastinate_finish_job.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.00.00_01_initial.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.05.00_01_drop_started_at_column.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.05.00_02_drop_started_at_column.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.05.00_03_drop_procrastinate_version_table.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.06.00_01_fix_procrastinate_fetch_job.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.07.01_01_fix_trigger_status_events_insert.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.08.01_01_add_queueing_lock_column.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.10.00_01_close_fetch_job_race_condition.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.10.00_02_add_defer_job_function.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.11.00_03_add_procrastinate_periodic_defers.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.12.00_01_add_foreign_key_index.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.14.00_01_add_locks_to_periodic_defer.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.15.02_01_fix_procrastinate_defer_periodic_job.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.16.00_01_add_finish_job_and_retry_job_functions.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.17.00_01_add_trigger_on_job_deletion.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.17.00_02_delete_finished_jobs.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.17.00_03_add_checks_to_finish_job.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.17.00_04_add_checks_to_retry_job.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.18.01_01_fix_finish_job_compat_issue.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.19.00_01_add_index_on_procrastinate_jobs.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.22.00_01_add_kwargs_to_defer_periodic_job.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.23.00_01_null_locks_excluded.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/01.00.00_01_remove_old_finish_job_function.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/01.01.01_01_job_id_bigint.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/02.00.03_01_add_job_priority.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/02.05.00_01_add_periodic_job_priority.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/02.06.00_01_add_cancel_states.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/02.08.00_01_add_additional_params_to_retry_job.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/02.14.01_01_add_indexes_for_fetch_job.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/03.00.00_01_pre_cancel_notification.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/03.00.00_50_post_cancel_notification.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/03.01.00_01_pre_add_heartbeat.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/03.01.00_50_post_add_heartbeat.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/03.02.00_01_pre_batch_defer_jobs.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/03.02.00_50_post_batch_defer_jobs.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/03.03.00_01_pre_priority_lock_fetch_job.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/03.04.00_01_pre_add_retry_failed_job_procedure.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/03.04.00_50_post_add_retry_failed_job_procedure.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/__init__.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/queries.sql +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/types.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/utils.py +0 -0
- {procrastinate-3.7.2 → procrastinate-3.8.0}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: procrastinate
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.8.0
|
|
4
4
|
Summary: Postgres-based distributed task processing library
|
|
5
5
|
Project-URL: homepage, https://procrastinate.readthedocs.io/
|
|
6
6
|
Project-URL: source, https://github.com/procrastinate-org/procrastinate/
|
|
@@ -359,7 +359,10 @@ class Blueprint:
|
|
|
359
359
|
cron: str,
|
|
360
360
|
periodic_id: str = "",
|
|
361
361
|
**configure_kwargs: Unpack[ConfigureTaskOptions],
|
|
362
|
-
)
|
|
362
|
+
) -> Callable[
|
|
363
|
+
[Task[P, R, Concatenate[int, periodic.Args]]],
|
|
364
|
+
Task[P, R, periodic.Args],
|
|
365
|
+
]:
|
|
363
366
|
"""
|
|
364
367
|
Task decorator, marks task as being scheduled for periodic deferring (see
|
|
365
368
|
`howto/advanced/cron`).
|
|
@@ -62,6 +62,20 @@ class BaseConnector:
|
|
|
62
62
|
) -> list[dict[str, Any]]:
|
|
63
63
|
raise exceptions.SyncConnectorConfigurationError
|
|
64
64
|
|
|
65
|
+
def execute_query_all_with_connection(
|
|
66
|
+
self, connection: Any, query: LiteralString, **arguments: Any
|
|
67
|
+
) -> list[dict[str, Any]]:
|
|
68
|
+
raise exceptions.ConnectorException(
|
|
69
|
+
f"{type(self).__name__} does not support external connections"
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
async def execute_query_all_async_with_connection(
|
|
73
|
+
self, connection: Any, query: LiteralString, **arguments: Any
|
|
74
|
+
) -> list[dict[str, Any]]:
|
|
75
|
+
raise exceptions.ConnectorException(
|
|
76
|
+
f"{type(self).__name__} does not support external connections"
|
|
77
|
+
)
|
|
78
|
+
|
|
65
79
|
async def listen_notify(
|
|
66
80
|
self,
|
|
67
81
|
on_notification: Notify,
|
|
@@ -103,6 +117,16 @@ class BaseAsyncConnector(BaseConnector):
|
|
|
103
117
|
) -> list[dict[str, Any]]:
|
|
104
118
|
return utils.async_to_sync(self.execute_query_all_async, query, **arguments)
|
|
105
119
|
|
|
120
|
+
def execute_query_all_with_connection(
|
|
121
|
+
self, connection: Any, query: LiteralString, **arguments: Any
|
|
122
|
+
) -> list[dict[str, Any]]:
|
|
123
|
+
return utils.async_to_sync(
|
|
124
|
+
self.execute_query_all_async_with_connection,
|
|
125
|
+
connection,
|
|
126
|
+
query,
|
|
127
|
+
**arguments,
|
|
128
|
+
)
|
|
129
|
+
|
|
106
130
|
async def listen_notify(
|
|
107
131
|
self, on_notification: Notify, channels: Iterable[str]
|
|
108
132
|
) -> None:
|
{procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/sqlalchemy/psycopg2_connector.py
RENAMED
|
@@ -192,3 +192,16 @@ class SQLAlchemyPsycopg2Connector(connector.BaseConnector):
|
|
|
192
192
|
# psycopg2's type say it returns a tuple, but it actually returns a
|
|
193
193
|
# dict when configured with RealDictCursor
|
|
194
194
|
return mapping.all() # pyright: ignore[reportReturnType]
|
|
195
|
+
|
|
196
|
+
@wrap_exceptions()
|
|
197
|
+
def execute_query_all_with_connection( # pyright: ignore[reportIncompatibleMethodOverride]
|
|
198
|
+
self,
|
|
199
|
+
connection: sqlalchemy.engine.Connection,
|
|
200
|
+
query: str,
|
|
201
|
+
**arguments: Any,
|
|
202
|
+
) -> list[Mapping[str, Any]]:
|
|
203
|
+
cursor_result = connection.exec_driver_sql(
|
|
204
|
+
PERCENT_PATTERN.sub("%%", query), self._wrap_json(arguments)
|
|
205
|
+
)
|
|
206
|
+
mapping = cursor_result.mappings()
|
|
207
|
+
return mapping.all() # pyright: ignore[reportReturnType]
|
|
@@ -147,9 +147,15 @@ class JobDeferrer:
|
|
|
147
147
|
doesn't need a job_manager property.
|
|
148
148
|
"""
|
|
149
149
|
|
|
150
|
-
def __init__(
|
|
150
|
+
def __init__(
|
|
151
|
+
self,
|
|
152
|
+
job_manager: manager.JobManager,
|
|
153
|
+
job: Job,
|
|
154
|
+
connection: Any | None = None,
|
|
155
|
+
):
|
|
151
156
|
self.job = job
|
|
152
157
|
self.job_manager = job_manager
|
|
158
|
+
self.connection = connection
|
|
153
159
|
|
|
154
160
|
def make_new_job(self, **task_kwargs: types.JSONValue) -> Job:
|
|
155
161
|
final_kwargs = self.job.task_kwargs.copy()
|
|
@@ -184,7 +190,9 @@ class JobDeferrer:
|
|
|
184
190
|
# Make sure this code stays synchronized with .defer()
|
|
185
191
|
job = self.make_new_job(**task_kwargs)
|
|
186
192
|
self._log_before_defer_jobs(jobs=[job])
|
|
187
|
-
job = await self.job_manager.defer_job_async(
|
|
193
|
+
job = await self.job_manager.defer_job_async(
|
|
194
|
+
job=job, connection=self.connection
|
|
195
|
+
)
|
|
188
196
|
self._log_after_defer_jobs(jobs=[job])
|
|
189
197
|
assert job.id # for mypy
|
|
190
198
|
return job.id
|
|
@@ -195,7 +203,9 @@ class JobDeferrer:
|
|
|
195
203
|
"""
|
|
196
204
|
jobs = [self.make_new_job(**kwargs) for kwargs in task_kwargs]
|
|
197
205
|
self._log_before_defer_jobs(jobs=jobs)
|
|
198
|
-
jobs = await self.job_manager.batch_defer_jobs_async(
|
|
206
|
+
jobs = await self.job_manager.batch_defer_jobs_async(
|
|
207
|
+
jobs=jobs, connection=self.connection
|
|
208
|
+
)
|
|
199
209
|
self._log_after_defer_jobs(jobs=jobs)
|
|
200
210
|
|
|
201
211
|
job_ids: list[int] = []
|
|
@@ -211,7 +221,7 @@ class JobDeferrer:
|
|
|
211
221
|
# Make sure this code stays synchronized with .defer_async()
|
|
212
222
|
job = self.make_new_job(**task_kwargs)
|
|
213
223
|
self._log_before_defer_jobs(jobs=[job])
|
|
214
|
-
job = self.job_manager.defer_job(job=job)
|
|
224
|
+
job = self.job_manager.defer_job(job=job, connection=self.connection)
|
|
215
225
|
self._log_after_defer_jobs(jobs=[job])
|
|
216
226
|
assert job.id # for mypy
|
|
217
227
|
return job.id
|
|
@@ -222,7 +232,7 @@ class JobDeferrer:
|
|
|
222
232
|
"""
|
|
223
233
|
jobs = [self.make_new_job(**kwargs) for kwargs in task_kwargs]
|
|
224
234
|
self._log_before_defer_jobs(jobs=jobs)
|
|
225
|
-
jobs = self.job_manager.batch_defer_jobs(jobs=jobs)
|
|
235
|
+
jobs = self.job_manager.batch_defer_jobs(jobs=jobs, connection=self.connection)
|
|
226
236
|
self._log_after_defer_jobs(jobs=jobs)
|
|
227
237
|
|
|
228
238
|
job_ids: list[int] = []
|
|
@@ -32,7 +32,11 @@ class JobManager:
|
|
|
32
32
|
def __init__(self, connector: connector.BaseConnector):
|
|
33
33
|
self.connector = connector
|
|
34
34
|
|
|
35
|
-
async def defer_job_async(
|
|
35
|
+
async def defer_job_async(
|
|
36
|
+
self,
|
|
37
|
+
job: jobs_module.Job,
|
|
38
|
+
connection: Any | None = None,
|
|
39
|
+
) -> jobs_module.Job:
|
|
36
40
|
"""
|
|
37
41
|
Add a job in its queue for later processing by a worker.
|
|
38
42
|
|
|
@@ -40,16 +44,20 @@ class JobManager:
|
|
|
40
44
|
----------
|
|
41
45
|
job:
|
|
42
46
|
The job to defer
|
|
47
|
+
connection:
|
|
48
|
+
Optional external database connection to use for the query.
|
|
43
49
|
|
|
44
50
|
Returns
|
|
45
51
|
-------
|
|
46
52
|
:
|
|
47
53
|
A copy of the job instance with the id set.
|
|
48
54
|
"""
|
|
49
|
-
return (await self.batch_defer_jobs_async(jobs=[job]))[0]
|
|
55
|
+
return (await self.batch_defer_jobs_async(jobs=[job], connection=connection))[0]
|
|
50
56
|
|
|
51
57
|
async def batch_defer_jobs_async(
|
|
52
|
-
self,
|
|
58
|
+
self,
|
|
59
|
+
jobs: list[jobs_module.Job],
|
|
60
|
+
connection: Any | None = None,
|
|
53
61
|
) -> list[jobs_module.Job]:
|
|
54
62
|
"""
|
|
55
63
|
Add multiple jobs in their queue for later processing by a worker.
|
|
@@ -58,6 +66,8 @@ class JobManager:
|
|
|
58
66
|
----------
|
|
59
67
|
jobs:
|
|
60
68
|
The jobs to defer
|
|
69
|
+
connection:
|
|
70
|
+
Optional external database connection to use for the query.
|
|
61
71
|
|
|
62
72
|
Returns
|
|
63
73
|
-------
|
|
@@ -66,9 +76,14 @@ class JobManager:
|
|
|
66
76
|
"""
|
|
67
77
|
# Make sure this code stays synchronized with .batch_defer_jobs()
|
|
68
78
|
try:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
79
|
+
if connection is not None:
|
|
80
|
+
results = await self.connector.execute_query_all_async_with_connection(
|
|
81
|
+
connection, **self._defer_jobs_query_kwargs(jobs=jobs)
|
|
82
|
+
)
|
|
83
|
+
else:
|
|
84
|
+
results = await self.connector.execute_query_all_async(
|
|
85
|
+
**self._defer_jobs_query_kwargs(jobs=jobs)
|
|
86
|
+
)
|
|
72
87
|
except exceptions.UniqueViolation as exc:
|
|
73
88
|
self._raise_already_enqueued(exc=exc, queueing_lock=exc.queueing_lock)
|
|
74
89
|
|
|
@@ -77,20 +92,33 @@ class JobManager:
|
|
|
77
92
|
for index, job in enumerate(jobs)
|
|
78
93
|
]
|
|
79
94
|
|
|
80
|
-
def defer_job(
|
|
95
|
+
def defer_job(
|
|
96
|
+
self,
|
|
97
|
+
job: jobs_module.Job,
|
|
98
|
+
connection: Any | None = None,
|
|
99
|
+
) -> jobs_module.Job:
|
|
81
100
|
"""
|
|
82
101
|
Sync version of `defer_job_async`.
|
|
83
102
|
"""
|
|
84
|
-
return self.batch_defer_jobs(jobs=[job])[0]
|
|
103
|
+
return self.batch_defer_jobs(jobs=[job], connection=connection)[0]
|
|
85
104
|
|
|
86
|
-
def batch_defer_jobs(
|
|
105
|
+
def batch_defer_jobs(
|
|
106
|
+
self,
|
|
107
|
+
jobs: list[jobs_module.Job],
|
|
108
|
+
connection: Any | None = None,
|
|
109
|
+
) -> list[jobs_module.Job]:
|
|
87
110
|
"""
|
|
88
111
|
Sync version of `batch_defer_jobs_async`.
|
|
89
112
|
"""
|
|
90
113
|
try:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
114
|
+
if connection is not None:
|
|
115
|
+
results = self.connector.get_sync_connector().execute_query_all_with_connection(
|
|
116
|
+
connection, **self._defer_jobs_query_kwargs(jobs=jobs)
|
|
117
|
+
)
|
|
118
|
+
else:
|
|
119
|
+
results = self.connector.get_sync_connector().execute_query_all(
|
|
120
|
+
**self._defer_jobs_query_kwargs(jobs=jobs)
|
|
121
|
+
)
|
|
94
122
|
except exceptions.UniqueViolation as exc:
|
|
95
123
|
self._raise_already_enqueued(exc=exc, queueing_lock=exc.queueing_lock)
|
|
96
124
|
|
|
@@ -200,9 +200,15 @@ class PsycopgConnector(connector.BaseAsyncConnector):
|
|
|
200
200
|
@contextlib.asynccontextmanager
|
|
201
201
|
async def _get_cursor(
|
|
202
202
|
self,
|
|
203
|
+
connection: psycopg.AsyncConnection | None = None,
|
|
203
204
|
) -> AsyncIterator[psycopg.AsyncCursor[psycopg.rows.DictRow]]:
|
|
204
|
-
|
|
205
|
-
|
|
205
|
+
conn_ctx = (
|
|
206
|
+
contextlib.nullcontext(connection)
|
|
207
|
+
if connection is not None
|
|
208
|
+
else self.pool.connection()
|
|
209
|
+
)
|
|
210
|
+
async with conn_ctx as conn:
|
|
211
|
+
async with conn.cursor(row_factory=psycopg.rows.dict_row) as cursor:
|
|
206
212
|
if self._json_loads:
|
|
207
213
|
psycopg.types.json.set_json_loads(
|
|
208
214
|
loads=self._json_loads, context=cursor
|
|
@@ -241,6 +247,18 @@ class PsycopgConnector(connector.BaseAsyncConnector):
|
|
|
241
247
|
|
|
242
248
|
return await cursor.fetchall()
|
|
243
249
|
|
|
250
|
+
@wrap_exceptions()
|
|
251
|
+
async def execute_query_all_async_with_connection(
|
|
252
|
+
self,
|
|
253
|
+
connection: psycopg.AsyncConnection,
|
|
254
|
+
query: LiteralString,
|
|
255
|
+
**arguments: Any,
|
|
256
|
+
) -> list[dict[str, Any]]:
|
|
257
|
+
async with self._get_cursor(connection=connection) as cursor:
|
|
258
|
+
await cursor.execute(query, self._wrap_json(arguments))
|
|
259
|
+
|
|
260
|
+
return await cursor.fetchall()
|
|
261
|
+
|
|
244
262
|
def _make_dynamic_query(
|
|
245
263
|
self,
|
|
246
264
|
query: LiteralString,
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
-- Procrastinate Schema
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
DO $$
|
|
4
|
+
BEGIN
|
|
5
|
+
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
|
|
6
|
+
EXCEPTION
|
|
7
|
+
WHEN OTHERS THEN
|
|
8
|
+
-- On managed PostgreSQL services (e.g. Azure Database for PostgreSQL, Amazon RDS,
|
|
9
|
+
-- Google Cloud SQL), CREATE EXTENSION may fail with various error codes:
|
|
10
|
+
-- insufficient_privilege, feature_not_supported, or provider-specific errors.
|
|
11
|
+
-- Before ignoring, verify the extension actually exists — if it does not exist
|
|
12
|
+
-- and cannot be created, re-raise so the failure is explicit.
|
|
13
|
+
IF EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'plpgsql') THEN
|
|
14
|
+
RAISE NOTICE 'plpgsql extension already exists, skipping creation.';
|
|
15
|
+
ELSE
|
|
16
|
+
RAISE;
|
|
17
|
+
END IF;
|
|
18
|
+
END;
|
|
19
|
+
$$;
|
|
4
20
|
|
|
5
21
|
-- Enums
|
|
6
22
|
|
|
@@ -155,9 +155,16 @@ class SyncPsycopgConnector(connector.BaseConnector):
|
|
|
155
155
|
return {key: self._wrap_value(value) for key, value in arguments.items()}
|
|
156
156
|
|
|
157
157
|
@contextlib.contextmanager
|
|
158
|
-
def _get_cursor(
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
def _get_cursor(
|
|
159
|
+
self, connection: psycopg.Connection | None = None
|
|
160
|
+
) -> Iterator[psycopg.Cursor[psycopg.rows.DictRow]]:
|
|
161
|
+
conn_ctx = (
|
|
162
|
+
contextlib.nullcontext(connection)
|
|
163
|
+
if connection is not None
|
|
164
|
+
else self.pool.connection()
|
|
165
|
+
)
|
|
166
|
+
with conn_ctx as conn:
|
|
167
|
+
with conn.cursor(row_factory=psycopg.rows.dict_row) as cursor:
|
|
161
168
|
if self._json_loads:
|
|
162
169
|
psycopg.types.json.set_json_loads(
|
|
163
170
|
loads=self._json_loads, context=cursor
|
|
@@ -195,3 +202,12 @@ class SyncPsycopgConnector(connector.BaseConnector):
|
|
|
195
202
|
cursor.execute(query, self._wrap_json(arguments))
|
|
196
203
|
|
|
197
204
|
return cursor.fetchall()
|
|
205
|
+
|
|
206
|
+
@wrap_exceptions()
|
|
207
|
+
def execute_query_all_with_connection(
|
|
208
|
+
self, connection: psycopg.Connection, query: LiteralString, **arguments: Any
|
|
209
|
+
) -> list[dict[str, Any]]:
|
|
210
|
+
with self._get_cursor(connection=connection) as cursor:
|
|
211
|
+
cursor.execute(query, self._wrap_json(arguments))
|
|
212
|
+
|
|
213
|
+
return cursor.fetchall()
|
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import datetime
|
|
4
4
|
import logging
|
|
5
5
|
from collections.abc import Callable
|
|
6
|
-
from typing import Generic, TypedDict, cast
|
|
6
|
+
from typing import Any, Generic, TypedDict, cast
|
|
7
7
|
|
|
8
8
|
from typing_extensions import NotRequired, ParamSpec, TypeVar, Unpack
|
|
9
9
|
|
|
@@ -27,6 +27,7 @@ class ConfigureTaskOptions(TypedDict):
|
|
|
27
27
|
schedule_in: NotRequired[types.TimeDeltaParams | None]
|
|
28
28
|
queue: NotRequired[str | None]
|
|
29
29
|
priority: NotRequired[int | None]
|
|
30
|
+
connection: NotRequired[Any | None]
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
def configure_task(
|
|
@@ -38,6 +39,7 @@ def configure_task(
|
|
|
38
39
|
schedule_at = options.get("schedule_at")
|
|
39
40
|
schedule_in = options.get("schedule_in")
|
|
40
41
|
priority = options.get("priority")
|
|
42
|
+
connection = options.get("connection")
|
|
41
43
|
|
|
42
44
|
if schedule_at and schedule_in is not None:
|
|
43
45
|
raise ValueError("Cannot set both schedule_at and schedule_in")
|
|
@@ -61,6 +63,7 @@ def configure_task(
|
|
|
61
63
|
priority=priority,
|
|
62
64
|
),
|
|
63
65
|
job_manager=job_manager,
|
|
66
|
+
connection=connection,
|
|
64
67
|
)
|
|
65
68
|
|
|
66
69
|
|
|
@@ -199,6 +202,12 @@ class Task(Generic[P, R, Args]):
|
|
|
199
202
|
Set the priority of the job as an integer. Jobs with higher priority
|
|
200
203
|
are run first. Priority can be positive or negative. The default priority
|
|
201
204
|
is 0.
|
|
205
|
+
connection :
|
|
206
|
+
An optional external database connection. When provided, the job INSERT
|
|
207
|
+
will run on this connection instead of the connector's pool, allowing
|
|
208
|
+
atomic deferral within a user-managed transaction. The user is
|
|
209
|
+
responsible for committing. Supported by ``SyncPsycopgConnector``,
|
|
210
|
+
``PsycopgConnector``, and ``SQLAlchemyPsycopg2Connector``.
|
|
202
211
|
|
|
203
212
|
Returns
|
|
204
213
|
-------
|
|
@@ -219,6 +228,7 @@ class Task(Generic[P, R, Args]):
|
|
|
219
228
|
schedule_in = options.get("schedule_in")
|
|
220
229
|
queue = options.get("queue")
|
|
221
230
|
priority = options.get("priority")
|
|
231
|
+
connection = options.get("connection")
|
|
222
232
|
|
|
223
233
|
app = cast(app_module.App, self.blueprint)
|
|
224
234
|
return configure_task(
|
|
@@ -233,6 +243,7 @@ class Task(Generic[P, R, Args]):
|
|
|
233
243
|
schedule_in=schedule_in,
|
|
234
244
|
queue=queue if queue is not None else self.queue,
|
|
235
245
|
priority=priority if priority is not None else self.priority,
|
|
246
|
+
connection=connection,
|
|
236
247
|
)
|
|
237
248
|
|
|
238
249
|
def get_retry_exception(
|
|
@@ -33,7 +33,7 @@ class InMemoryConnector(connector.BaseAsyncConnector):
|
|
|
33
33
|
methods and attributes to ease testing.
|
|
34
34
|
"""
|
|
35
35
|
|
|
36
|
-
def __init__(self):
|
|
36
|
+
def __init__(self) -> None:
|
|
37
37
|
self.reset()
|
|
38
38
|
self.reverse_queries = {value: key for key, value in sql.queries.items()}
|
|
39
39
|
self.reverse_queries[schema.SchemaManager.get_schema()] = "apply_schema"
|
|
@@ -89,6 +89,16 @@ class InMemoryConnector(connector.BaseAsyncConnector):
|
|
|
89
89
|
) -> list[dict[str, Any]]:
|
|
90
90
|
return await self.generic_execute(query, "all", **arguments)
|
|
91
91
|
|
|
92
|
+
def execute_query_all_with_connection(
|
|
93
|
+
self, connection: Any, query: str, **arguments: Any
|
|
94
|
+
) -> list[dict[str, Any]]:
|
|
95
|
+
return utils.async_to_sync(self.execute_query_all_async, query, **arguments)
|
|
96
|
+
|
|
97
|
+
async def execute_query_all_async_with_connection(
|
|
98
|
+
self, connection: Any, query: str, **arguments: Any
|
|
99
|
+
) -> list[dict[str, Any]]:
|
|
100
|
+
return await self.execute_query_all_async(query, **arguments)
|
|
101
|
+
|
|
92
102
|
async def listen_notify(
|
|
93
103
|
self, on_notification: connector.Notify, channels: Iterable[str]
|
|
94
104
|
) -> None:
|
|
@@ -354,9 +354,9 @@ class Worker:
|
|
|
354
354
|
if self.additional_context
|
|
355
355
|
else {},
|
|
356
356
|
job=job,
|
|
357
|
-
abort_reason=lambda:
|
|
358
|
-
|
|
359
|
-
|
|
357
|
+
abort_reason=lambda: (
|
|
358
|
+
self._job_ids_to_abort.get(job_id) if job_id else None
|
|
359
|
+
),
|
|
360
360
|
start_timestamp=time.time(),
|
|
361
361
|
)
|
|
362
362
|
job_task = asyncio.create_task(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/django_connector.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/management/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/0001_initial.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations/__init__.py
RENAMED
|
File without changes
|
{procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/migrations_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
{procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/django/procrastinate_app.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/contrib/psycopg2/psycopg2_connector.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{procrastinate-3.7.2 → procrastinate-3.8.0}/procrastinate/sql/migrations/00.00.00_01_initial.sql
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|