kombu.pidbox — Kombu v1.3.2 documentation

### Navigation

- index
- modules |
- next |
- previous |
- Kombu v1.3.2 documentation »
- API Reference »

# kombu.pidbox

Generic process mailbox.

copyright: | 2009 - 2011 by Ask Solem.
license: | BSD, see LICENSE for more details.

- Introduction
  - Creating the applications Mailbox
  - Example Node
  - Example Client
- Mailbox
- Node

## Introduction

### Creating the applications Mailbox

    >>> 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

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

### Example Client

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

## Mailbox

class `kombu.pidbox.` `Mailbox`(namespace, type='direct', connection=None)
  `namespace`

    Name of application.

  `connection`

    Connection (if bound).

  `type`

    Exchange type (usually direct, or fanout for broadcast).

  `exchange`

    mailbox exchange (init by constructor).

  `reply_exchange`

    exchange to send replies to.

  `Node`(hostname=None, state=None, channel=None, handlers=None)
  `call`(destination, command, kwargs={}, timeout=None, callback=None, channel=None)
  `cast`(destination, command, kwargs={})
  `abcast`(command, kwargs={})
  `multi_call`(command, kwargs={}, timeout=1, limit=None, callback=None, channel=None)
  `get_reply_queue`(ticket)
  `get_queue`(hostname)

## Node

class `kombu.pidbox.` `Node`(hostname, state=None, channel=None, handlers=None, mailbox=None)
  `hostname`

    hostname of the node.

  `mailbox`

    the `Mailbox` this is a node for.

  `handlers`

    map of method name/handlers.

  `state`

    current context (passed on to handlers)

  `channel`

    current channel.

  `Consumer`(channel=None, **options)
  `handler`(fun)
  `listen`(channel=None, callback=None)
  `dispatch`(method, arguments=None, reply_to=None)
  `dispatch_from_message`(message)
  `handle_call`(method, arguments)
  `handle_cast`(method, arguments)
  `handle`(method, arguments={})
  `handle_message`(body, message)
  `reply`(data, exchange, routing_key, **kwargs)

### Navigation

- index
- modules |
- next |
- previous |
- Kombu v1.3.2 documentation »
- API Reference »