Я использую модуль django_notification. https://github.com/pinax/django-notification/blob/master/docs/usage.txtЯ не понимаю эту документацию Django. Как использовать этот модуль?
Это то, что я в своем коде, чтобы отправить письмо пользователю, когда что-то происходит:
notification.send([to_user], "comment_received", noti_dict)
Но это, кажется, чтобы блокировать запрос. И это занимает много времени, чтобы отправить его. Я читаю документы, и он говорит, что его можно добавить в очередь (асинхронно). Как добавить его в асинхронную очередь?
Я не понимаю, что документы пытаются сказать. Что такое «emit_notices»? Когда я это называю? У меня есть сценарий, который вызывает это каждые 5 секунд? Это глупо. Каков правильный способ сделать это асинхронно? Что я делаю?
Lets first break down what each does.
``send_now``
~~~~~~~~~~~~
This is a blocking call that will check each user for elgibility of the
notice and actually peform the send.
``queue``
~~~~~~~~~
This is a non-blocking call that will queue the call to ``send_now`` to
be executed at a later time. To later execute the call you need to use
the ``emit_notices`` management command.
``send``
~~~~~~~~
A proxy around ``send_now`` and ``queue``. It gets its behavior from a global
setting named ``NOTIFICATION_QUEUE_ALL``. By default it is ``False``. This
setting is meant to help control whether you want to queue any call to
``send``.
``send`` also accepts ``now`` and ``queue`` keyword arguments. By default
each option is set to ``False`` to honor the global setting which is ``False``.
This enables you to override on a per call basis whether it should call
``send_now`` or ``queue``.