core.message — PyZMQ v2.1.1dev documentation

### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- API »
- The PyZMQ API »

# core.message

## Module: `core.message`

Inheritance diagram for `zmq.core.message`:

0MQ Message related classes.

## Classes

### `Message`

class `zmq.core.message.` `Message`(data=None, track=False)

  Bases: `object`

  A Message class for non-copy send/recvs.

  This class is only needed if you want to do non-copying send and recvs. When you pass a string to this class, like `Message(s)`, the ref-count of s is increased by two: once because the Message saves s as an instance attribute and another because a ZMQ message is created that points to the buffer of s. This second ref-count increase makes sure that s lives until all messages that use it have been sent. Once 0MQ sends all the messages and it doesn’t need the buffer of s, 0MQ will call `Py_DECREF(s)`.

  Parameters : | data : object, optional any object that provides the buffer interface will be used to construct the 0MQ message data. track : bool [default: False] whether a MessageTracker should be created to track this object. Tracking a message has a cost at creation, because it creates a threadsafe Queue object.

  `buffer`

    Get a read-only buffer view of the message contents.

  `bytes`

    Get the message content as a Python str/bytes object.

    The first time this property is accessed, a copy of the message contents is made. From then on that same copy of the message is returned.

  `done`

    Is 0MQ completely done with the message?

  `tracker`
  `tracker_queue`
  `wait`(timeout=-1)

    Wait for 0MQ to be done with the message, or until timeout.

    Parameters : | timeout : float [default: -1, wait forever] Maximum time in (s) to wait before raising NotDone.
    Returns : | None : if done before timeout
    Raises : | NotDone : if timeout reached before I am done.

### `MessageTracker`

class `zmq.core.message.` `MessageTracker`(*towatch)

  Bases: `object`

  A class for tracking if 0MQ is done using one or more messages.

  When you send a 0MQ mesage, it is not sent immeidately. The 0MQ IO thread send the message at some later time. Often you want to know when 0MQ has actually sent the message though. This is complicated by the fact that a single 0MQ message can be sent multiple times using differen sockets. This class allows you to track all of the 0MQ usages of a message.

  Parameters : | *towatch : tuple of Queue, MessageTracker, Message instances. This list of objects to track. This class can track the low-level Queues used by the Message class, other MessageTrackers or actual Messsages.

  `done`

    Is 0MQ completely done with the message(s) being tracked?

  `old_wait`()

    If the new wait works, remove this method.

  `wait`(timeout=-1)

    Wait for 0MQ to be done with the message, or until timeout.

    Parameters : | timeout : float [default: -1, wait forever] Maximum time in (s) to wait before raising NotDone.
    Returns : | None : if done before timeout
    Raises : | NotDone : if timeout reached before I am done.

### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- API »
- The PyZMQ API »