Package: django-user-tasks
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 inOEP-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.Overviewdjango-user-tasks is currently a wrapper forCelery(although the hope is
that it could also be extended to also supportchannelsand other
asynchronous task queues).  By extending the providedUserTaskclass (or
addingUserTaskMixinto an existing Task subclass) and providing auser_idtask argument, the task’s status is stored in a database table
separate from the Celery broker and result store.  ThisUserTaskStatusmodel 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’ssignalsmechanism, but it can be enhanced by:Overriding theUserTaskMixinmethods such asgenerate_nameandcalculate_total_stepsfor particular types of tasksCalling some of theUserTaskStatusmethods likeincrement_completed_stepsandset_statefrom the task implementationSaving task output as instances of theUserTaskArtifactmodelDocumentationThe full documentation is athttps://django-user-tasks.readthedocs.org.LicenseThe code in this repository is licensed under the Apache Software License 2.0 unless
otherwise noted.Please seeLICENSE.txtfor details.How To ContributeContributions are very welcome.Please readHow To Contributefor details.Reporting Security IssuesPlease do not report security issues in public. Please emailsecurity@edx.org.Getting HelpHave a question about this repository, or about Open edX in general?  Please
refer to thislist of resourcesif you need any assistance.Change LogUnreleased[3.1.0] - 2023-07-21AddedAdded Django42 support in CI.RemovedRemoved old versions of celery and drf version from ci.ChoreSwitch fromedx-sphinx-themetosphinx-book-themesince the former is
deprecated[3.0.0] - 2022-02-09RemovedRemoved Python 3.5 support.ChoreUpgraded celery to latest 5.x version.[2.2.0] - 2022-01-26RemovedRemoved Django22,30,31 support.AddedAdded Django40 support in CI[2.1.0] - 2021-07-07AddedSupport for django3.0, 3.1 and 3.2[2.0.3] - 2021-06-08ChangedFixed django admin timeout issue.[2.0.2] - 2021-05-28ChangedFixed minor issue. If links key is not available assign empty list. Added logs.[2.0.1] - 2021-05-28AddedAdded 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-20RemovedRemoved python3.5 support.[1.3.2] - 2020-12-17ChangedAdded celery 5.0 testing using tox. Fix pylint warnings. Update the code accordingly.[1.3.2] - 2020-12-17ChangedUpdated the deprecated celery import class. New import is compatible with 4.4.7 also.[1.3.1] - 2020-11-23AddedAdded support for Django REST Framework 3.10.x through 3.12.x[1.3.0] - 2020-08-25AddedAdded support for celery 4[1.2.0] - 2020-08-20RemovedRemoved code related to Python 2[1.1.0] - 2020-05-07AddedAdded support for python 3.8RemovedDropped support for Django < 2.2[1.0.0] - 2020-03-18RemovedDropped Python 2.7 support[0.3.0] - 2019-12-15AddedAdded support for Django 2.2[0.2.1] - 2019-09-25Changedstart_user_taskshould 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-30ChangedHave thestart_user_taskreceiver close obsolete connections before starting the task.[0.1.9] - 2019-08-27ChangedFix issue withUserTaskArtifactAdminandUserTaskStatusAdminwhereorderingattribute must be a tuple or list.[0.1.8] - 2019-08-22ChangedImprove list display forModelAdmin.[0.1.7] - 2019-05-29ChangedMakeUserTaskArtifact.urlaTextFieldwith aURLValidatorinstead of aURLField.[0.1.6] - 2019-05-29ChangedUpgrade requirements.Changemax_lengthofUserTaskArtifact.urlfrom 200 to 512.[0.1.5] - 2017-08-03ChangedAdded testing/support for Django 1.11.[0.1.4] - 2017-01-30ChangedSlightly 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-03ChangedTasks which were explicitly canceled, failed, or retried no longer have
their status changed toSucceededjust 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 thebefore_task_publishsignal handler.[0.1.2] - 2016-12-05ChangedAdd 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 preventmakemigrationsfrom creating a new migration whenever the setting value changes.[0.1.1] - 2016-10-11ChangedFix 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-07AddedFirst attempt to release on PyPI.