Repository navigation
A task no longer runs twice when several workers share a queue, a task whose code cannot be imported fails visibly instead of hanging in RUNNING, and the queue can be monitored from code and from /tasks/status/. Windows Server is now a supported place to run the worker.
Existing projects need no changes, with one exception: TaskBroker.enqueue(), deprecated in 0.5, is now gone — see Removed below.
Added
- Windows Server.
GracefulShutdownhandlesSIGBREAK, so a worker stopped with Ctrl-Break or by a service manager finishes the running task before exiting. The README gained NSSM and WinSW service examples and a Task Scheduler shape for running from a job scheduler. - A monitoring API.
get_queue_stats()returns the counts per status, the number of delayed tasks not yet due, and how long the oldest and newest pending task has been waiting;get_task_counts()returns the counts alone. The keys are those of django-tasks-redis, so one collector reads both. - Purging one task's results.
purge_completed_database_tasks --task-pathandtask_pathon/tasks/purge/delete only the results of that task, such as a heartbeat enqueued every minute. - Purging from your own code.
purge_completed_tasks()does what the command does, for a project that purges from a periodic task. Its defaults follow django-tasks-redis: thedefaultbackend only, keeping the last 7 days. The command and the endpoint keep their defaults. - Simplified Chinese, Brazilian Portuguese and Spanish translations of the admin and the management command help.
- Task path and priority filters in the admin task list.
Changed
GET /tasks/status/returns the queue stats alongsidepending_count, which is unchanged, as is the endpoint's authentication.
Removed
TaskBroker.enqueue(), deprecated in 0.5 and removed here as announced. A broker that overrides it instead ofnotify()is no longer called, and every task logsBroker X failed to notify about task Yat ERROR; the task stays in the database, so the worker and the HTTP endpoints still run it. Rename the method tonotify(). Bundled brokers and theBROKERoption are unaffected.
Fixed
- A task could run twice when more than one worker polled the same queue.
run_task()now claims the task in a locked transaction and returnsNonefor a task another worker claimed first. - A task whose function could not be imported was left
RUNNINGwith no error recorded. It is nowFAILEDwith the traceback, so the admin shows it and Retry failed tasks runs it again once the code is fixed. - An invalid
--empty-exit-codeor--failed-exit-codeprinted a traceback and exited 1; it is now a usage error with exit code 2. - Two broker-path log records now carry the fields the README documents.
- The admin column headers and the management command help are now translated.
See CHANGELOG.md for the full entry, including the test suite changes for Windows.
Full Changelog: v0.5.0...v0.6.0