summaryrefslogtreecommitdiff
path: root/docs/reference/kombu.pidbox.rst
blob: e64676139e074dac8644bf9fb5a9276400f7bd7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
=========================================
 Pidbox - ``kombu.pidbox``
=========================================


.. currentmodule:: kombu.pidbox

.. automodule:: kombu.pidbox

    .. contents::
        :local:

    Introduction
    ------------

    Creating the applications Mailbox
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    .. code-block:: python

        >>> mailbox = pidbox.Mailbox('celerybeat', type='direct')

        >>> @mailbox.handler
        >>> def reload_schedule(state, **kwargs):
        ...     state['beat'].reload_schedule()

        >>> @mailbox.handler
        >>> def connection_info(state, **kwargs):
        ...     return {'connection': state['connection'].info()}

    Example Node
    ~~~~~~~~~~~~

    .. code-block:: python

        >>> connection = kombu.Connection()
        >>> state = {'beat': beat,
                     'connection': connection}
        >>> consumer = mailbox(connection).Node(hostname).listen()
        >>> try:
        ...     while True:
        ...         connection.drain_events(timeout=1)
        ... finally:
        ...     consumer.cancel()

    Example Client
    ~~~~~~~~~~~~~~

    .. code-block:: python

        >>> mailbox.cast('reload_schedule')   # cast is async.
        >>> info = celerybeat.call('connection_info', timeout=1)

    Mailbox
    -------

    .. autoclass:: Mailbox

        .. autoattribute:: namespace
        .. autoattribute:: connection
        .. autoattribute:: type
        .. autoattribute:: exchange
        .. autoattribute:: reply_exchange

        .. automethod:: Node
        .. automethod:: call
        .. automethod:: cast
        .. automethod:: abcast
        .. automethod:: multi_call
        .. automethod:: get_reply_queue
        .. automethod:: get_queue

    Node
    ----

    .. autoclass:: Node

        .. autoattribute:: hostname
        .. autoattribute:: mailbox
        .. autoattribute:: handlers
        .. autoattribute:: state
        .. autoattribute:: channel

        .. automethod:: Consumer
        .. automethod:: handler
        .. automethod:: listen
        .. automethod:: dispatch
        .. automethod:: dispatch_from_message
        .. automethod:: handle_call
        .. automethod:: handle_cast
        .. automethod:: handle
        .. automethod:: handle_message
        .. automethod:: reply