简体   繁体   中英

Is sleep() blocking the handling of requests in Django?

In Django, if the view uses a sleep() function while answering a request, does this block the handling of the whole queue of requests?

If so, how to delay an http answer without this blocking behavior? Can we do that out-of-the-box and avoid using a job queue like Celeri?

I would image that calling sleep() should block the execution of all Django code in most cases. However it might depend on the deployment architecture (eg gevent, gunicorn, etc). For instance if you are using a server which fires Django threads for each request, then no it will not block all the code.

In most cases however using something like Celeri would like to be a much better solution because (1) don't reinvent the wheel and (2) it has been tested.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM