devices.basedevice — PyZMQ v2.1.1dev documentation

### Navigation

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

# devices.basedevice

## Module: `devices.basedevice`

Inheritance diagram for `zmq.devices.basedevice`:

Classes for running 0MQ Devices in the background.

### Authors

- MinRK
- Brian Granger

## Classes

### `BackgroundDevice`

class `zmq.devices.basedevice.` `BackgroundDevice`(device_type, in_type, out_type)

  Bases: `zmq.devices.basedevice.Device`

  Base class for launching Devices in background processes and threads.

  `bind_in`(addr)

    Enqueue ZMQ address for binding on in_socket.

    See zmq.Socket.bind for details.

  `bind_out`(iface)

    Enqueue ZMQ address for binding on out_socket.

    See zmq.Socket.bind for details.

  `connect_in`(addr)

    Enqueue ZMQ address for connecting on in_socket.

    See zmq.Socket.connect for details.

  `connect_out`(iface)

    Enqueue ZMQ address for connecting on out_socket.

    See zmq.Socket.connect for details.

  `join`(timeout=None)
  `run`()

    The runner method.

    Do not call me directly, instead call `self.start()`, just like a Thread.

  `setsockopt_in`(opt, value)

    Enqueue setsockopt(opt, value) for in_socket

    See zmq.Socket.setsockopt for details.

  `setsockopt_out`(opt, value)

    Enqueue setsockopt(opt, value) for out_socket

    See zmq.Socket.setsockopt for details.

  `start`()

### `Device`

class `zmq.devices.basedevice.` `Device`(device_type, in_type, out_type)

  A Threadsafe 0MQ Device.

  Warning as with most ‘threadsafe’ Python objects, this is only threadsafe as long as you do not use private methods or attributes. Private names are prefixed with ‘_’, such as `self._setup_socket()`.

  For thread safety, you do not pass Sockets to this, but rather Socket types:

      Device(device_type, in_socket_type, out_socket_type)

  For instance:

      dev = Device(zmq.QUEUE, zmq.XREQ, zmq.XREP)

  Similar to zmq.device, but socket types instead of sockets themselves are passed, and the sockets are created in the work thread, to avoid issues with thread safety. As a result, additional bind_{in|out} and connect_{in|out} methods and setsockopt_{in|out} allow users to specify connections for the sockets.

  Parameters : | device_type : int The 0MQ Device type {in|out}_type : int zmq socket types, to be passed later to context.socket(). e.g. zmq.PUB, zmq.SUB, zmq.REQ. If out_type is < 0, then in_socket is used for both in_socket and out_socket.
  Attributes : | daemon : int sets whether the thread should be run as a daemon Default is true, because if it is false, the thread will not exit unless it is killed
  Methods : | bind_{in_out}(iface) : passthrough for `{in|out}_socket.bind(iface)`, to be called in the thread connect_{in_out}(iface) : passthrough for `{in|out}_socket.connect(iface)`, to be called in the thread setsockopt_{in_out}(opt,value) : passthrough for `{in|out}_socket.setsockopt(opt, value)`, to be called in the thread

  `bind_in`(addr)

    Enqueue ZMQ address for binding on in_socket.

    See zmq.Socket.bind for details.

  `bind_out`(iface)

    Enqueue ZMQ address for binding on out_socket.

    See zmq.Socket.bind for details.

  `connect_in`(addr)

    Enqueue ZMQ address for connecting on in_socket.

    See zmq.Socket.connect for details.

  `connect_out`(iface)

    Enqueue ZMQ address for connecting on out_socket.

    See zmq.Socket.connect for details.

  `join`(timeout=None)

    wait for me to finish, like Thread.join.

    Reimplemented appropriately by sublcasses.

  `run`()

    The runner method.

    Do not call me directly, instead call `self.start()`, just like a Thread.

  `setsockopt_in`(opt, value)

    Enqueue setsockopt(opt, value) for in_socket

    See zmq.Socket.setsockopt for details.

  `setsockopt_out`(opt, value)

    Enqueue setsockopt(opt, value) for out_socket

    See zmq.Socket.setsockopt for details.

  `start`()

    Start the device. Override me in subclass for other launchers.

### `ProcessDevice`

class `zmq.devices.basedevice.` `ProcessDevice`(device_type, in_type, out_type)

  Bases: `zmq.devices.basedevice.BackgroundDevice`

  A Device that will be run in a background Process.

  See Device for details.

  `bind_in`(addr)

    Enqueue ZMQ address for binding on in_socket.

    See zmq.Socket.bind for details.

  `bind_out`(iface)

    Enqueue ZMQ address for binding on out_socket.

    See zmq.Socket.bind for details.

  `connect_in`(addr)

    Enqueue ZMQ address for connecting on in_socket.

    See zmq.Socket.connect for details.

  `connect_out`(iface)

    Enqueue ZMQ address for connecting on out_socket.

    See zmq.Socket.connect for details.

  `join`(timeout=None)
  `run`()

    The runner method.

    Do not call me directly, instead call `self.start()`, just like a Thread.

  `setsockopt_in`(opt, value)

    Enqueue setsockopt(opt, value) for in_socket

    See zmq.Socket.setsockopt for details.

  `setsockopt_out`(opt, value)

    Enqueue setsockopt(opt, value) for out_socket

    See zmq.Socket.setsockopt for details.

  `start`()

### `ThreadDevice`

class `zmq.devices.basedevice.` `ThreadDevice`(device_type, in_type, out_type)

  Bases: `zmq.devices.basedevice.BackgroundDevice`

  A Device that will be run in a background Thread.

  See Device for details.

  `bind_in`(addr)

    Enqueue ZMQ address for binding on in_socket.

    See zmq.Socket.bind for details.

  `bind_out`(iface)

    Enqueue ZMQ address for binding on out_socket.

    See zmq.Socket.bind for details.

  `connect_in`(addr)

    Enqueue ZMQ address for connecting on in_socket.

    See zmq.Socket.connect for details.

  `connect_out`(iface)

    Enqueue ZMQ address for connecting on out_socket.

    See zmq.Socket.connect for details.

  `join`(timeout=None)
  `run`()

    The runner method.

    Do not call me directly, instead call `self.start()`, just like a Thread.

  `setsockopt_in`(opt, value)

    Enqueue setsockopt(opt, value) for in_socket

    See zmq.Socket.setsockopt for details.

  `setsockopt_out`(opt, value)

    Enqueue setsockopt(opt, value) for out_socket

    See zmq.Socket.setsockopt for details.

  `start`()

### Navigation

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