- -
-

pyams_zmq package

- -
-

Submodules

-
-
-

pyams_zmq.handler module

-
-
-class pyams_zmq.handler.ZMQMessageHandler(process, stream, stop, handler=None, json_load=-1)
-

Bases: object

-

Base class for message handlers for a pyams_zmq.process.Process.

-

Inheriting classes only need to implement a handler function for each -message type.

-
-
-handler = None
-
- -
- -
-
-

pyams_zmq.process module

-
-
-class pyams_zmq.process.ZMQProcess(bind_addr, handler)
-

Bases: multiprocessing.context.Process

-

This is the base for all processes and offers utility methods -for setup and creating new streams.

-
-
-context = None
-

The ØMQ Context instance.

-
- -
-
-exit(num, frame)
-
- -
-
-initStream()
-

Initialize response stream

-
- -
-
-loop = None
-

PyZMQ’s event loop (IOLoop).

-
- -
-
-run()
-

Sets up everything and starts the event loop.

-
- -
-
-setup()
-

Creates a context and an event loop for the process.

-
- -
-
-socket_type = 4
-
- -
-
-stop()
-

Stops the event loop.

-
- -
-
-stream(sock_type, addr, bind, callback=None, subscribe=b'')
-

Creates a ZMQStream.

- --- - - - - - -
Parameters:
    -
  • sock_type – The ØMQ socket type (e.g. zmq.REQ)
  • -
  • addr

    Address to bind or connect to formatted as host:port, -(host, port) or host (bind to random port). -If bind is True, host may be:

    -
      -
    • the wild-card *, meaning all available interfaces,
    • -
    • the primary IPv4 address assigned to the interface, in its
    • -
    -

    numeric representation or -- the interface name as defined by the operating system.

    -

    If bind is False, host may be:

    -
      -
    • the DNS name of the peer or
    • -
    • the IPv4 address of the peer, in its numeric representation.
    • -
    -

    If addr is just a host name without a port and bind is -True, the socket will be bound to a random port.

    -
  • -
  • bind – Binds to addr if True or tries to connect to it -otherwise.
  • -
  • callback – A callback for -on_recv(), optional
  • -
  • subscribe – Subscription pattern for SUB sockets, optional, -defaults to b''.
  • -
-
Returns:

A tuple containg the stream and the port number.

-
-
- -
- -
-
-pyams_zmq.process.process_exit_func(process=None)
-
- -
-
-

pyams_zmq.socket module

-
-
-pyams_zmq.socket.zmq_response(socket, flags=1, timeout=10)
-

Get response from given socket

-
- -
-
-pyams_zmq.socket.zmq_socket(address, socket_type=3, linger=0, protocol='tcp')
-

Get ØMQ socket

-
- -
-
-

Module contents

-
-
-pyams_zmq.includeme(config)
-

Pyramid include

-
- -
-
- - -