Skip to content

Commit 0ea57ec

Browse files
committed
Document prioritising jobs
1 parent 99b382c commit 0ea57ec

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,20 @@ Using the name you configured for your job in your settings, create an instance
114114
Job.objects.create(name='my_job')
115115
```
116116

117+
### Prioritising jobs
118+
Sometimes it is necessary for certain jobs to take precedence over others. For example; you may have a worker which has a primary purpose of dispatching somewhat
119+
important emails to users. However, once an hour, you may need to run a _really_ important job which needs to be done on time and cannot wait in the queue for dozens
120+
of emails to be dispatched before it can begin.
121+
122+
In order to make sure that an important job is run before others, you can set the `priority` field to an integer higher than `0` (the default). For example:
123+
```python
124+
Job.objects.create(name='normal_job')
125+
Job.objects.create(name='important_job', priority=1)
126+
Job.objects.create(name='critical_job', priority=2)
127+
```
128+
129+
Jobs will be ordered by their `priority` (highest to lowest) and then the time which they were created (oldest to newest) and processed in that order.
130+
117131
## Terminology
118132

119133
### Job

0 commit comments

Comments
 (0)