Discussion:
What is meant by blocking request in django?
(too old to reply)
Kharis
2018-11-30 03:58:30 UTC
Permalink
Once I worked on a feature that use API like sending emails from my app, I
write the code inside the django app.
My superior told me that causes request to block, so another request will
be blocked until the process of calling the API finished and response sent
to user.
He suggest that this process better off offloaded to celery.

I thought this can be solved by using multiple worker as in gunicorn, so
another client can be served by another worker if there's available.
but, both he and I don't have a clue if above (solved by creating multiple
worker) is true.

so, does it mean by blocking, it only blocks a single process/worker? or do
all worker have to wait?
and what is another possible blocking request scenario? generating pdf?
long calculation?

in addition, where can I read about blocking request in django? I searched
but, really hard to find one
--
This message and any attachments may contain confidential information and
are intended only for the use of the intended recipient(s). Any disclosure,
distribution or copying of this message and any attachments is strictly
prohibited without approval from PT. Wisanamitra Argakarya. If you are not
the intended recipient, you should notify the sender and delete this
message immediately. PT. Wisanamitra Argakarya is not liable for any damage
caused by any virus or malicious file transmitted by this message. Any
views, opinions, or commitments expressed in this message do not
necessarily reflect the views of PT. Wisanamitra Argakarya.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5fe5627f-a6ae-476e-a863-2389289e9802%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ryan Nowakowski
2018-11-30 14:01:03 UTC
Permalink
This is how I think about blocking in the context of Django. Anything that takes time and is not directly related to returning an http response should be done in the background (via celery or whatever). Your email example is a good one. The email doesn't need to be sent before the http response is returned so you should send email via celery. In general anything that "blocks" the http response unnecessarily should be done in the background.
Post by Kharis
Once I worked on a feature that use API like sending emails from my app, I
write the code inside the django app.
My superior told me that causes request to block, so another request will
be blocked until the process of calling the API finished and response sent
to user.
He suggest that this process better off offloaded to celery.
I thought this can be solved by using multiple worker as in gunicorn, so
another client can be served by another worker if there's available.
but, both he and I don't have a clue if above (solved by creating multiple
worker) is true.
so, does it mean by blocking, it only blocks a single process/worker? or do
all worker have to wait?
and what is another possible blocking request scenario? generating pdf?
long calculation?
in addition, where can I read about blocking request in django? I searched
but, really hard to find one
--
This message and any attachments may contain confidential information and
are intended only for the use of the intended recipient(s). Any
disclosure,
distribution or copying of this message and any attachments is strictly
prohibited without approval from PT. Wisanamitra Argakarya. If you are not
the intended recipient, you should notify the sender and delete this
message immediately. PT. Wisanamitra Argakarya is not liable for any damage
caused by any virus or malicious file transmitted by this message. Any
views, opinions, or commitments expressed in this message do not
necessarily reflect the views of PT. Wisanamitra Argakarya.
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/5fe5627f-a6ae-476e-a863-2389289e9802%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/DB501022-4257-4249-9FD2-52DAAE3400AE%40fattuba.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...