私は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``.