For really long-running tasks, even a progress bar isn't all that user friendly. It still requires them to hang around with a browser window open. A really nice feature would be the ability to let users opt-in to some kind of notification when their task is done.
Jobtastic can do this with a keyword argument on the task combined with a JobtasticNotifierTask. The idea would be to add something like
allow_user_notification = True
on the task. Then, with a supplied Django View or Flask request handler, the user can opt in to being notified about the task from the page where they're waiting for results. When the original JobtasticTask finishes, it checks a known cache location (based off of cache_prefix) to see if any users have opted in to notifications. If they have, it fires off a JobtasticNotifierTask right before it was finished.
This task then checks the same cache location and uses the configured JOBTASTIC_NOTIFICATION_BACKENDS to notify the given user.
We can probably start with these backends for good coverage of common use-cases:
Flask-Mail backend that just accepts an email address
Django user email notification backend that takes a django.contrib.auth.models.User id and fires off an email to their user.email using Django's send_mail
For really long-running tasks, even a progress bar isn't all that user friendly. It still requires them to hang around with a browser window open. A really nice feature would be the ability to let users opt-in to some kind of notification when their task is done.
Jobtastic can do this with a keyword argument on the task combined with a
JobtasticNotifierTask
. The idea would be to add something likeon the task. Then, with a supplied Django View or Flask request handler, the user can opt in to being notified about the task from the page where they're waiting for results. When the original
JobtasticTask
finishes, it checks a known cache location (based off ofcache_prefix
) to see if any users have opted in to notifications. If they have, it fires off aJobtasticNotifierTask
right before it was finished.This task then checks the same cache location and uses the configured
JOBTASTIC_NOTIFICATION_BACKENDS
to notify the given user.We can probably start with these backends for good coverage of common use-cases:
django.contrib.auth.models.User
id and fires off an email to their user.email using Django's send_mail