labscript_utils.ls_zprocess.Context¶
- class labscript_utils.ls_zprocess.Context(io_threads=1, shared_secret=None)[source]¶
Bases:
zprocess.security.SecureContext
Subclass 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
(*args, **kwargs)Create a Socket associated with this Context.
term
()Close or terminate the context.
Attributes
client_publickey
client_secretkey
closed
secure
server_publickey
server_secretkey
underlying
The address of the underlying libzmq context
- 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(*args, **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 or a subclass) –
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.
New in version 25.
kwargs – will be passed to the __init__ method of the socket class.