If the code that triggers a user_ isĬontained in a database transaction, note that the Celery task may startīefore the new UserTaskStatus record has been committed to the database.ĭjango-user-tasks tries to compensate for this, but it can still lead toĮrrors in some pathological timing scenarios, so try to avoid creating such The signal’s sender is the UserTaskStatus class,Īnd its status argument is the instance of that class for which the signal was sent.
The status change, log relevant statistics, etc. Listeners can use this signal to notify users of Succeeded), a user_er_task_stopped signal is sent. When a subclass of user_ reaches any end state ( Canceled, Failed, or register ( r 'user_tasks/', StatusViewSet, base_name = 'usertaskstatus' ) urlpatterns = ROUTER. register ( r 'user_task_artifacts', ArtifactViewSet, base_name = 'usertaskartifact' ) ROUTER.
For example:įrom rest_framework.routers import SimpleRouter from user_tasks.views import ArtifactViewSet, StatusViewSet ROUTER = SimpleRouter () ROUTER. Service’s overall URL configuration, or create a custom configuration which uses paths of your choice. Out of the box, django-user-tasks provides a urls module containing a URLconf which places the REST APIĮndpoints under tasks/ and artifacts/. There’s an indication of how far along execution of the task has progressed,Īnd while in progress the status reflects the name of the section currently Now the name of the task includes the name of the course being exported, increment_completed_steps () UserTaskArtifact.
get ( pk = arguments_dict ) return 'Export of '. From celery import shared_task from user_tasks.models import UserTaskArtifact from user_tasks.tasks import UserTask from my_app.models import Course class ExportTask ( UserTask ): def generate_name ( cls, arguments_dict ): course = Course.