X
X
Xcopy2014-12-11 14:00:03
Django
Xcopy, 2014-12-11 14:00:03

How does Django multithreading work?

Hello!
I am writing a server for a mobile application on the Android OS.
In order for me to send Push notifications to phones, I use the standard Google GCM service , and in Django I work with it through the django-gcm module.
It all looks something like this: each Android user has its own ID, and passing it and a message to django-gcm, it sends it to GCM, and from there a Push notification is sent to the Android user. Everything is simple.
But, when I want to send Push to all users at once, and go through a loop through all of them (there is no send to all function at once), it feels like the whole Django hangs and stops responding to requests from other users.
In this regard, the question is: how does multithreading work in Django? Is the server fully multi-threaded?
And how then to organize such mass mailings? Perhaps it should be done through some RabbitMQ?
Thanks in advance for your reply

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Andrey K, 2014-12-11
@mututunus

Django doesn't have multithreading. To run tasks in the "background" use Celery .

A
alternativshik, 2014-12-11
@alternativshik

Mikhail : If such a mailing does not depend on the server in any way (it does not start when submitting a form or calling a view, for example), then you can do it through management commands + cron

I
Ilya, 2014-12-11
@FireGM

Off topic, but implementing this in jung is a bad practice, no?

A
asmrnv777, 2016-03-10
@asmrnv777

In GCM, you can send a message to many recipients at once (like up to 1024 pcs.).
In addition, there is something like "channels", I don't remember the exact terminology, read the GCM docs. The bottom line is that the application subscribes to a channel, say, /news/social/, and you send one message from the server to this channel, and all subscribers receive it at once.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question