Skip to content

Commit 475c3e0

Browse files
committed
Merge branch 'queue-depth-utils' of github.com:dabapps/django-db-queue into queue-depth-utils
2 parents 7ea4e51 + 65f86ac commit 475c3e0

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Asynchronous tasks are run via a *job queue*. This system is designed to support
99

1010
Supported and tested against:
1111
- Django 1.11 and 2.2
12-
- Python 3.7 and 3.8
12+
- Python 3.5, 3.6, 3.7 and 3.8
1313

1414
This package may still work with older versions of Django and Python but they aren't explicitly supported.
1515

@@ -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

django_dbq/management/commands/worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class Command(BaseCommand):
104104
def add_arguments(self, parser):
105105
parser.add_argument("queue_name", nargs="?", default="default", type=str)
106106
parser.add_argument(
107-
"rate_limit",
107+
"--rate_limit",
108108
help="The rate limit in seconds. The default rate limit is 1 job per second.",
109109
nargs="?",
110110
default=1,

0 commit comments

Comments
 (0)