8000 Merge pull request #326 from peopledoc/ele_remove-old-jobs · Develop-Python/procrastinate@ad02649 · GitHub
[go: up one dir, main page]

Skip to content

Commit ad02649

Browse files
author
Joachim Jablon
authored
Merge pull request procrastinate-org#326 from peopledoc/ele_remove-old-jobs
2 parents ede161d + 419f30f commit ad02649

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

docs/howto/django.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Configure your procrastinate app from your Django settings::
3434
connector=procrastinate.Psycopg2Connector(**connector_params())
3535
)
3636

37-
(See `connector` for more on how to instanciate your connector.)
37+
(See `connector` for more on how to instantiate your connector.)
3838

3939
Procrastinate comes with its own migrations so don't forget to run ``./manage.py
4040
migrate``.

docs/howto/remove_old_jobs.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,22 @@ For example, to use a queueing lock:
4545
4646
The call to ``defer`` will raise an `AlreadyEnqueued` exception if there already is
4747
a "remove_old_jobs" job waiting in the queue, which you may want to catch and ignore.
48+
49+
As mentioned in the previous section you may want to run ``remove_old_jobs``
50+
periodically. For that you may use a Unix cron, or rely on Procrastinate's "periodic
51+
tasks" functionality. This is how you can make ``remove_old_jobs`` periodic:
52+
53+
.. code-block:: python
54+
55+
@app.periodic(cron="0 4 * * *")
56+
@app.task(queueing_lock="remove_old_jobs", pass_context=True)
57+
async def remove_old_jobs(context, timestamp):
58+
return await app.builtin_tasks["remove_old_jobs"](
59+
context=context,
60+
max_hours=72,
61+
remove_error=True,
62+
)
63+
64+
With this you define your own ``remove_old_jobs`` task, which relies on Procrastinate's
65+
builtin ``remove_old_jobs`` task function. The task is periodic, and configured to be
66+
deferred every day at 4 am.

docs/spelling_wordlist.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ app
33
async
44
asynchronicity
55
attrs
6+
autogenerated
67
backend
78
backoff
89
builtin
@@ -24,6 +25,8 @@ GitHub
2425
Godwin
2526
healthcheck
2627
healthchecks
28+
linter
29+
linters
2730
linting
2831
localhost
2932
middleware

procrastinate/contrib/django/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def connector_params(alias: str = "default") -> Dict[str, Any]:
5050
Returns
5151
-------
5252
``Dict[str, Any]``
53-
Provide these keyword arguments when instanciating your connector
53+
Provide these keyword arguments when instantiating your connector
5454
"""
5555
wrapper = connections[alias]
5656
return wrapper.get_connection_params()

0 commit comments

Comments
 (0)
0