labscript_utils.ls_zprocess.Context
- class labscript_utils.ls_zprocess.Context(io_threads=1, shared_secret=None)[source]
Bases:
SecureContextSubclass of zprocess.security.SecureContext configured with settings from labconfig, substitutable for a zmq.Context. Can be instantiated to get a unique context, or call the .instance() classmethod to possibly get an already-existing one. Only use the latter if you do not indent to terminate the context.
Methods
__init__([io_threads, shared_secret])destroy([linger])Close all sockets associated with this context and then terminate the context.
get(option)Get the value of a context option.
getsockopt(opt)get default socket options for new sockets created by this Context
instance()Returns a shared instance with the same shared secret, if there is one, otherwise creates it.
set(option, optval)Set a context option.
setsockopt(opt, value)set default socket options for new sockets created by this Context
shadow(address)Shadow an existing libzmq context
shadow_pyczmq(ctx)Shadow an existing pyczmq context
socket(socket_type[, socket_class])Create a Socket associated with this Context.
term()Close or terminate the context.
Attributes
authclient_publickeyclient_secretkeyclosedsecureserver_publickeyserver_secretkeyunderlyingThe address of the underlying libzmq context
zap_domainsockopts- classmethod instance()[source]
Returns a shared instance with the same shared secret, if there is one, otherwise creates it. If an instance already exists, io_threads will be ignored, otherwise it will be used in the new instance. Takes into account subclasses such that a subclass calling this method will always get back an instance of its own class
- socket(socket_type, socket_class=None, **kwargs)[source]
Create a Socket associated with this Context.
- Parameters:
socket_type (int) – The socket type, which can be any of the 0MQ socket types: REQ, REP, PUB, SUB, PAIR, DEALER, ROUTER, PULL, PUSH, etc.
socket_class (zmq.Socket) –
The socket class to instantiate, if different from the default for this Context. e.g. for creating an asyncio socket attached to a default Context or vice versa.
Added in version 25.
kwargs – will be passed to the __init__ method of the socket class.