Skip to content

Commit 0513e7c

Browse files
author
Johannes Erwerle
committed
improved docs on running jobs with an instance
1 parent 5f77d68 commit 0513e7c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

docs/plugins/development/background-jobs.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ Four of the standard Python logging levels are supported:
6060

6161
Log entries recorded using the runner's logger will be saved in the job's log in the database in addition to being processed by other [system logging handlers](../../configuration/system.md#logging).
6262

63+
### Jobs running for Model instances
64+
65+
A Job can be run for a certain instance of a Model.
66+
To support this, the `JobsMixin` is required for this model.
67+
68+
To assign an instance to a Job use the `instance` parameter when enqueuing the Job.
69+
6370
### Scheduled Jobs
6471

6572
As described above, jobs can be scheduled for immediate execution or at any later time using the `enqueue()` method. However, for management purposes, the `enqueue_once()` method allows a job to be scheduled exactly once avoiding duplicates. If a job is already scheduled for a particular instance, a second one won't be scheduled, respecting thread safety. An example use case would be to schedule a periodic task that is bound to an instance in general, but not to any event of that instance (such as updates). The parameters of the `enqueue_once()` method are identical to those of `enqueue()`.

0 commit comments

Comments
 (0)