Skip to content

Commit 936c1e0

Browse files
committed
fix:preventing creating migration for queue field.
fix #119
1 parent 9d9ca11 commit 936c1e0

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

docs/index.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# Django tasks Scheduler
22

3-
[![Django CI](https://github.com/dsoftwareinc/django-tasks-scheduler/actions/workflows/test.yml/badge.svg)](https://github.com/dsoftwareinc/django-tasks-scheduler/actions/workflows/test.yml)
4-
![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/cunla/b756396efb895f0e34558c980f1ca0c7/raw/django-tasks-scheduler-4.json)
5-
[![badge](https://img.shields.io/pypi/dm/django-tasks-scheduler)](https://pypi.org/project/django-tasks-scheduler/)
6-
[![Open Source Helpers](https://www.codetriage.com/dsoftwareinc/django-tasks-scheduler/badges/users.svg)](https://www.codetriage.com/dsoftwareinc/django-tasks-scheduler)
3+
[![Django CI][1]][2]
4+
![badge][3]
5+
[![badge][4]][5]
76

87
---
98

10-
A database backed async tasks scheduler for django.
9+
A database backed asynchronous tasks scheduler for django.
1110
This allows remembering scheduled tasks, their parameters, etc.
1211

1312
## Terminology
@@ -66,19 +65,19 @@ sequenceDiagram
6665
end
6766
box DB
6867
participant db as Database
69-
68+
7069
end
7170
box Redis queue
7271
participant queue as Queue
7372
participant schedule as Queue scheduled tasks
74-
end
73+
end
7574
loop Scheduler process - loop forever
76-
note over scheduler,schedule: Database interaction
75+
note over scheduler, schedule: Database interaction
7776
scheduler ->> db: Check for enabled tasks that should be scheduled
7877
critical There are tasks to be scheduled
7978
scheduler ->> schedule: Create a job for task that should be scheduled
8079
end
81-
note over scheduler,schedule: Redis queues interaction
80+
note over scheduler, schedule: Redis queues interaction
8281
scheduler ->> schedule: check whether there are scheduled tasks that should be executed
8382
critical there are jobs that are scheduled to be executed
8483
scheduler ->> schedule: remove jobs to be scheduled
@@ -100,10 +99,10 @@ sequenceDiagram
10099
participant queue as Queue
101100
participant finished as Queue finished jobs
102101
participant failed as Queue failed jobs
103-
end
102+
end
104103
loop Worker process - loop forever
105104
worker ->>+ queue: get the first job to be executed
106-
queue -->>- worker: A job to be executed or nothing
105+
queue -->>- worker: A job to be executed or nothing
107106
critical There is a job to be executed
108107
worker ->> queue: Remove job from queue
109108
worker ->> worker: Execute job
@@ -113,8 +112,8 @@ sequenceDiagram
113112
worker ->> failed: Write job result
114113
end
115114
option No job to be executed
116-
worker ->> worker: sleep
117-
end
115+
worker ->> worker: sleep
116+
end
118117
end
119118
```
120119

@@ -129,3 +128,9 @@ Please report issues via [GitHub Issues](https://github.com/dsoftwareinc/django-
129128
## Acknowledgements
130129

131130
A lot of django-admin views and their tests were adopted from [django-rq](https://github.com/rq/django-rq).
131+
132+
[1]:https://github.com/dsoftwareinc/django-tasks-scheduler/actions/workflows/test.yml/badge.svg
133+
[2]:https://github.com/dsoftwareinc/django-tasks-scheduler/actions/workflows/test.yml
134+
[3]:https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/cunla/b756396efb895f0e34558c980f1ca0c7/raw/django-tasks-scheduler-4.json
135+
[4]:https://img.shields.io/pypi/dm/django-tasks-scheduler
136+
[5]:https://pypi.org/project/django-tasks-scheduler/

scheduler/apps.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ class SchedulerConfig(AppConfig):
88
verbose_name = _('Tasks Scheduler')
99

1010
def ready(self):
11-
pass
11+
from scheduler.models import BaseTask
12+
from scheduler.settings import QUEUES
13+
14+
BaseTask.QUEUES = [(queue, queue) for queue in QUEUES.keys()]

scheduler/models/scheduled_task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def success_callback(job, connection, result, *args, **kwargs):
6363
class BaseTask(models.Model):
6464
created = models.DateTimeField(auto_now_add=True)
6565
modified = models.DateTimeField(auto_now=True)
66-
QUEUES = [(key, key) for key in settings.QUEUES.keys()]
66+
QUEUES = [("default", "default"), ("low", "low"), ("high", "high")]
6767
TASK_TYPE = 'BaseTask'
6868
name = models.CharField(
6969
_('name'), max_length=128, unique=True,

testproject/testproject/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@
124124
'high': {
125125
'URL': 'redis://localhost:6379/1',
126126
},
127+
'medium': {
128+
'URL': 'redis://localhost:6379/1',
129+
},
127130
}
128131
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
129132

0 commit comments

Comments
 (0)