Skip to main content
PyPI CI Codecov Documentation Supported Python versions License

django-user-tasks is a reusable Django application for managing user-triggered asynchronous tasks. It provides a status page for each such task, which includes a meaningful progress indicator if the task is currently being executed and provides any appropriate text and/or links for output once the task is complete.

In Open edX, such tasks include operations such as exporting or importing a course, sending an email to all the students in a course, uploading a video, and other tasks which often take too long to perform during a single web request (as outlined in OEP-3). However, this has been written with the intention of being useful in a variety of Django projects outside the Open edX platform as well.

Note that this library was created as a consolidation of lessons learned from implementing such tasks in various parts of the Open edX code base. They don’t yet all use this library, but the plan is to over time refactor many of them to do so.

Overview

django-user-tasks is currently a wrapper for Celery (although the hope is that it could also be extended to also support channels and other asynchronous task queues). By extending the provided UserTask class (or adding UserTaskMixin to an existing Task subclass) and providing a user_id task argument, the task’s status is stored in a database table separate from the Celery broker and result store. This UserTaskStatus model allows for full database queries of the tasks that users are most likely to care about while not imposing any restrictions on the Celery configuration most appropriate for the site’s overall needs for asynchronous task processing.

Most of the status updating is handled automatically via Celery’s signals mechanism, but it can be enhanced by:

  • Overriding the UserTaskMixin methods such as generate_name and calculate_total_steps for particular types of tasks

  • Calling some of the UserTaskStatus methods like increment_completed_steps and set_state from the task implementation

  • Saving task output as instances of the UserTaskArtifact model

Documentation

The full documentation is at https://django-user-tasks.readthedocs.org.

License

The code in this repository is licensed under the Apache Software License 2.0 unless otherwise noted.

Please see LICENSE.txt for details.

How To Contribute

Contributions are very welcome.

Please read How To Contribute for details.

Reporting Security Issues

Please do not report security issues in public. Please email security@openedx.org.

Getting Help

Have a question about this repository, or about Open edX in general? Please refer to this list of resources if you need any assistance.

Change Log

Unreleased

[3.4.3] - 2025-08-06

Fixed

  • Fix Celery protocol v2 header parameter name from task_id to id in extract_proto2_headers function

[3.4.2] - 2025-06-24

Changed * Support Celery protocol V2 in create_user_tasks

[3.4.1] - 2025-04-20

Changed

  • Fix get_storage method.

[3.4.0] - 2025-04-05

Added

  • Added Django 5.2 support

[3.3.0] - 2025-02-13

Removed

  • Removed python 3.8 support

  • Updated requirements with python 3.11 env

[3.2.0] - 2024-03-12

Added

  • Adding python 3.11 support.

  • Adding python 3.12 support.

  • Removed django32 support.

[3.1.0] - 2023-07-21

Added

  • Added Django42 support in CI.

Removed

  • Removed old versions of celery and drf version from ci.

Chore

  • Switch from edx-sphinx-theme to sphinx-book-theme since the former is deprecated

[3.0.0] - 2022-02-09

Removed

  • Removed Python 3.5 support.

Chore

  • Upgraded celery to latest 5.x version.

[2.2.0] - 2022-01-26

Removed

  • Removed Django22,30,31 support.

Added

  • Added Django40 support in CI

[2.1.0] - 2021-07-07

Added

  • Support for django3.0, 3.1 and 3.2

[2.0.3] - 2021-06-08

Changed

  • Fixed django admin timeout issue.

[2.0.2] - 2021-05-28

Changed

  • Fixed minor issue. If links key is not available assign empty list. Added logs.

[2.0.1] - 2021-05-28

Added

  • Added celery5.0 testing with tox. Update the import task command compatible with both celery 4.4.7 and celery5.0.

[2.0.0] - 2021-01-20

Removed

  • Removed python3.5 support.

[1.3.2] - 2020-12-17

Changed

  • Added celery 5.0 testing using tox. Fix pylint warnings. Update the code accordingly.

[1.3.2] - 2020-12-17

Changed

  • Updated the deprecated celery import class. New import is compatible with 4.4.7 also.

[1.3.1] - 2020-11-23

Added

  • Added support for Django REST Framework 3.10.x through 3.12.x

[1.3.0] - 2020-08-25

Added

  • Added support for celery 4

[1.2.0] - 2020-08-20

Removed

  • Removed code related to Python 2

[1.1.0] - 2020-05-07

Added

  • Added support for python 3.8

Removed

  • Dropped support for Django < 2.2

[1.0.0] - 2020-03-18

Removed

  • Dropped Python 2.7 support

[0.3.0] - 2019-12-15

Added

  • Added support for Django 2.2

[0.2.1] - 2019-09-25

Changed

  • start_user_task should only close obsolete connections if the current connection is NOT in an atomic block (which fixes errors on devstack studio/course-publishing).

[0.2.0] - 2019-08-30

Changed

  • Have the start_user_task receiver close obsolete connections before starting the task.

[0.1.9] - 2019-08-27

Changed

  • Fix issue with UserTaskArtifactAdmin and UserTaskStatusAdmin where ordering attribute must be a tuple or list.

[0.1.8] - 2019-08-22

Changed

  • Improve list display for ModelAdmin.

[0.1.7] - 2019-05-29

Changed

  • Make UserTaskArtifact.url a TextField with a URLValidator instead of a URLField.

[0.1.6] - 2019-05-29

Changed

  • Upgrade requirements.

  • Change max_length of UserTaskArtifact.url from 200 to 512.

[0.1.5] - 2017-08-03

Changed

  • Added testing/support for Django 1.11.

[0.1.4] - 2017-01-30

Changed

  • Slightly improved handling of tasks which start before their status records are committed (due to database transactions). Also documented how to avoid this problem in the first place.

[0.1.3] - 2017-01-03

Changed

  • Tasks which were explicitly canceled, failed, or retried no longer have their status changed to Succeeded just because the task exited cleanly.

  • Celery tasks which fail to import cleanly by name (because they use a custom name which isn’t actually the fully qualified task name) are now just ignored in the before_task_publish signal handler.

[0.1.2] - 2016-12-05

Changed

  • Add a migration to explicitly reference the setting for artifact file storage. This setting is likely to vary between installations, but doesn’t affect the generated database schema. This change should prevent makemigrations from creating a new migration whenever the setting value changes.

[0.1.1] - 2016-10-11

Changed

  • Fix Travis configuration for PyPI deployments.

  • Switch from the Read the Docs Sphinx theme to the Open edX one for documentation.

[0.1.0] - 2016-10-07

Added

  • First attempt to release on PyPI.

Release files for django-user-tasks 4.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-user-tasks 4.0.0
File Size Uploaded
django_user_tasks-4.0.0.tar.gz 35.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-user-tasks 4.0.0
File Interpreter ABI Platform
django_user_tasks-4.0.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 64.9 kB

Release files / django_user_tasks-4.0.0.tar.gz

Download URL django_user_tasks-4.0.0.tar.gz
Size 35.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a5939b916babb56fd04b026aa0a0242f059b7b9ac33ac6e59ed176d1f3606e9c
BLAKE2b-256 checksum
How to use checksums
5fd7e8e07bdcb729aaeb44adea129dcb8c22908ecf38cb274d8ab2690c2c536a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / django_user_tasks-4.0.0-py2.py3-none-any.whl

Download URL django_user_tasks-4.0.0-py2.py3-none-any.whl
Size 29.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
62ff7612926f238fa0b4773bd64e6de87cbdf6f785a8274209877aeef1a1908f
BLAKE2b-256 checksum
How to use checksums
b6f438dfb19784cc3cd179d1557134df2bbc94d401d03b1197f143e7f39bc74c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

4.0.0 This release

2 release files

3.4.4

2 release files

3.4.3

2 release files

3.4.2

2 release files

3.4.1

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page