On Tuesday 21 February 2017 13:11:19 John, Steffen wrote:
> Using celery, is it possible to prevent the user from doing other
> things in the admin tool until the celery task is done?
Sorta kinda.
But the django admin can facilitate part of it. Look into the ModelAdmin.has_FOO_permission() methods. These get passed the request. So you could implement something like:
- set has_job_running on User profile model
- for possibly dangerous actions, return false for the has_FOO_permission() method if request.user.profile.has_job_running is True.
- on job end, reset the user's has_job_running flag.
You can refine this to a tee, with different completion stages for the job opening up otherwise denied actions, etc etc.
The timeout however, is something with your webserver / wsgi implementation and you should look there. For example, nginx has several timeouts for handling a WSGI request that come into play. Increasing those, also means you tie up resources and are more succeptable to denial of service, so if celery is an option, take it.
--
Melvyn Sopacua
No comments:
Post a Comment