Skip to content

v0.6.0

Latest

Choose a tag to compare

@tokibito tokibito released this 30 Sep 16:08
· 9 commits to main since this release
de641e5

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. GracefulShutdown handles SIGBREAK, 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-path and task_path on /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: the default backend 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 alongside pending_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 of notify() is no longer called, and every task logs Broker X failed to notify about task Y at ERROR; the task stays in the database, so the worker and the HTTP endpoints still run it. Rename the method to notify(). Bundled brokers and the BROKER option 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 returns None for a task another worker claimed first.
  • A task whose function could not be imported was left RUNNING with no error recorded. It is now FAILED with the traceback, so the admin shows it and Retry failed tasks runs it again once the code is fixed.
  • An invalid --empty-exit-code or --failed-exit-code printed 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