@@ -39,29 +39,51 @@ def long_running_func():
39
39
long_running_func.delay() # Enqueue function with a timeout of 3600 seconds.
40
40
```
41
41
42
- You can set in ` settings.py ` a default value for ` DEFAULT_RESULT_TTL ` and ` DEFAULT_TIMEOUT ` .
42
+ You can set in ` settings.py ` a default value for ` DEFAULT_JOB_TTL ` and ` DEFAULT_JOB_TIMEOUT ` .
43
43
44
44
``` python
45
45
# settings.py
46
- SCHEDULER_CONFIG = {
47
- ' DEFAULT_RESULT_TTL' : 360 ,
48
- ' DEFAULT_TIMEOUT' : 60 ,
49
- }
46
+ SCHEDULER_CONFIG = SchedulerConfig(
47
+ DEFAULT_SUCCESS_TTL = 10 * 60 , # Time To Live (TTL) in seconds to keep successful job results
48
+ DEFAULT_FAILURE_TTL = 365 * 24 * 60 * 60 , # Time To Live (TTL) in seconds to keep job failure information
49
+ DEFAULT_JOB_TTL = 10 * 60 , # Time To Live (TTL) in seconds to keep job information
50
+ DEFAULT_JOB_TIMEOUT = 5 * 60 , # timeout (seconds) for a job
51
+ )
50
52
```
51
53
52
- ## Scheduling a job Through django-admin
54
+ ## Managing tasks through the Django Admin
55
+
56
+ ### Viewing list of scheduled tasks
57
+
58
+ ![ ] ( media/admin-tasks-list.jpg )
59
+
60
+ ### Viewing details of a scheduled task
61
+
62
+ It is possible to view list of executions of a task, as well as the details of a specific execution.
63
+ ![ ] ( media/admin-task-details.jpg )
64
+
65
+ ### Scheduling a task Through django-admin
53
66
54
67
* Sign in to the Django Admin site (e.g., http://localhost:8000/admin/ ) and locate the ` Tasks Scheduler ` section.
55
- * Click on the ** Add** link for the type of job you want to add (` Scheduled Task ` - run once, ` Repeatable Task ` - run
56
- multiple times, ` Cron Task ` - Run based on cron schedule).
57
- * Enter a unique name for the job in the ** Name** field.
68
+ * Click on the ** Add** on ` Tasks `
69
+ * Enter a unique name for the task in the ** Name** field.
70
+ * Select the task type, and according to the type, the form will change for the scheduling details.
71
+ * For ` Repeatable task `
72
+ * Enter an Interval, and choose the Interval unit. This will calculate the time before the function is called
73
+ again.
74
+ * In the Repeat field, enter the number of times the job is to be run. Leaving the field empty, means the job
75
+ will be scheduled to run forever.
76
+ * For ` Cron task `
77
+ * In the Repeat field, enter the number of times the job is to be run. Leaving the field empty, means the job
78
+ will be scheduled to run forever.
79
+ * In the cron string field, enter a cron string describing how often the job should run.
58
80
* In the ** Callable** field, enter a Python dot notation path to the method that defines the job. For the example
59
81
above, that would be ` myapp.jobs.count `
60
82
* Choose your ** Queue** .
61
83
The queues listed are defined in your app ` settings.py ` under ` SCHEDULER_QUEUES ` .
62
84
* Enter the time in UTC the job is to be executed in the ** Scheduled time** field.
63
85
64
- ![ ] ( media/add-scheduled-job .jpg )
86
+ ![ ] ( media/add-scheduled-task .jpg )
65
87
66
88
#### Optional fields:
67
89
@@ -75,33 +97,28 @@ SCHEDULER_CONFIG = {
75
97
76
98
Once you are done, click ** Save** and your job will be persisted to django database.
77
99
78
- ### Support for arguments for jobs
100
+ #### Support for arguments for tasks
79
101
80
- django-tasks-scheduler supports scheduling jobs calling methods with arguments, as well as arguments that should be
102
+ django-tasks-scheduler supports scheduling tasks calling methods with arguments, as well as arguments that should be
81
103
calculated in runtime.
82
104
83
105
![ ] ( media/add-args.jpg )
84
106
85
- ### Scheduled Task: run once
107
+ ### Viewing queue statistics
86
108
87
- No additional steps are required.
109
+ ![ ] ( media/admin-queues-list.jpg )
88
110
89
- ### Repeatable Task: Run a job multiple time based on interval
111
+ ### Viewing queue specific registry jobs
90
112
91
- These additional fields are required:
113
+ ![ ] ( media/admin-queue-registry.jpg )
92
114
93
- * Enter an ** Interval** , and choose the ** Interval unit** . This will calculate the time before the function is called
94
- again.
95
- * In the ** Repeat** field, enter the number of time the job is to be run. Leaving the field empty, means the job will
96
- be scheduled to run forever.
115
+ ### Viewing workers list
97
116
98
- ### Cron Task: Run a job multiple times based on cron
117
+ ![ ] ( media/admin-workers-list.jpg )
99
118
100
- These additional fields are required:
119
+ ### Viewing worker details
101
120
102
- * In the ** Repeat** field, enter the number of time the job is to be run. Leaving the field empty, means the job will be
103
- scheduled to run forever.
104
- * In the ** cron string** field, enter a cron string describing how often the job should run.
121
+ ![ ] ( media/admin-worker-details.jpg )
105
122
106
123
## Enqueue jobs using the command line
107
124
@@ -123,7 +140,7 @@ usage: manage.py scheduler_worker [-h] [--pid PIDFILE] [--name NAME] [--worker-t
123
140
[queues ...]
124
141
```
125
142
126
- More information about the different parameters can be found in the [ commands documentation] ( commands.md ) .
143
+ More information about the different parameters can be found in the [ commands documentation] ( commands.md ) .
127
144
128
145
### Running multiple workers as unix/linux services using systemd
129
146
0 commit comments