HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib64/python3.6/site-packages/zmq/sugar/__pycache__/context.cpython-36.opt-1.pyc
3

VS�_t#�@s�dZddlZddlZddlmZddlmZddlmZ	ddl
mZddlm
Z
dd	lmZmZmZdd
lmZddlmZdad
d�Zeje�Gdd�de	e
�ZdgZdS)zPython bindings for 0MQ.�N)�Lock)�WeakSet)�Context�)�	constants)�AttributeSetter)�ENOTSUP�LINGER�
ctx_opt_names)�Socket)�ZMQErrorFcCsdadS)NT)�_exiting�rr�/usr/lib64/python3.6/context.py�_notice_atexitsrcs�eZdZdZdZdZe�ZdZdZ	dZ
d-�fdd�	Zdd�Zd	d
�Z
dd�Zd.d
d�ZeZedd��Zedd��Zed/dd��Z�fdd�Zdd�Zdd�Zdd�Zd0dd�Zedd ��Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Z d+d,�Z!�Z"S)1rz[Create a zmq Context

    A zmq Context creates sockets via its ``ctx.socket`` method.
    NFrcsFtt|�jfd|i|��|jdd�r.d|_nd|_i|_t�|_dS)N�
io_threads�shadowFT)�superr�__init__�get�_shadow�sockoptsr�_sockets)�selfr�kwargs)�	__class__rrr&szContext.__init__cCs t�|jrtr|j�dS)zMdeleting a Context should terminate it, without trying non-threadsafe destroyN)�localsrr
�term)rrrr�__del__/szContext.__del__cCs|S)Nr)rrrr�	__enter__8szContext.__enter__cOs|j�dS)N)r)r�argsrrrr�__exit__;szContext.__exit__cCs|jj|j�S)z'Copying a Context creates a shadow copy)rr�
underlying)r�memorrr�__copy__>szContext.__copy__cCsddlm}||�}||d�S)z�Shadow an existing libzmq context
        
        address is the integer address of the libzmq context
        or an FFI pointer to it.
        
        .. versionadded:: 14.1
        r)�
cast_int_addr)r)�zmq.utils.interopr%)�cls�addressr%rrrrDs	zContext.shadowcCs4ddlm}ddlm}|j|�}||�}||d�S)z�Shadow an existing pyczmq context
        
        ctx is the FFI `zctx_t *` pointer
        
        .. versionadded:: 14.1
        r)�zctx)r%)r)Zpyczmqr)r&r%r")r'Zctxr)r%r"r(rrr�
shadow_pyczmqQs

zContext.shadow_pyczmqc
Csn|jdks |jtj�ks |jjrh|j�<|jdksH|jtj�ksH|jjr^||d�|_tj�|_WdQRX|jS)aReturns a global Context instance.

        Most single-threaded applications have a single, global Context.
        Use this method instead of passing around Context instances
        throughout your code.

        A common pattern for classes that depend on Contexts is to use
        a default argument to enable programs with multiple Contexts
        but not require the argument for simpler applications::

            class MyClass(object):
                def __init__(self, context=None):
                    self.context = context or Context.instance()

        .. versionchanged:: 18.1

            When called in a subprocess after forking,
            a new global instance is created instead of inheriting
            a Context that won't work from the parent process.
        N)r)�	_instance�
_instance_pid�os�getpid�closed�_instance_lock)r'rrrr�instanceas

zContext.instancecstt|�j�S)aLClose or terminate the context.

        Context termination is performed in the following steps:

        - Any blocking operations currently in progress on sockets open within context shall
          raise :class:`zmq.ContextTerminated`.
          With the exception of socket.close(), any further operations on sockets open within this context
          shall raise :class:`zmq.ContextTerminated`.
        - After interrupting all blocking calls, term shall block until the following conditions are satisfied:
            - All sockets open within context have been closed.
            - For each socket within context, all messages sent on the socket have either been
              physically transferred to a network peer,
              or the socket's linger period set with the zmq.LINGER socket option has expired.

        For further details regarding socket linger behaviour refer to libzmq documentation for ZMQ_LINGER.

        This can be called to close the context by hand. If this is not called,
        the context will automatically be closed when it is garbage collected.
        )rrr)r)rrrr�szContext.termcCs(t|j�}xtfD]}|j|�qW|S)N)�dirrr
�extend)r�keysZ
collectionrrr�__dir__�s


zContext.__dir__cCs|jj|�dS)N)r�add)r�socketrrr�_add_socket�szContext._add_socketcCs|jr|jj|�dS)N)r�discard)rr7rrr�
_rm_socket�szContext._rm_socketcCsZ|jr
dS|j}t�|_x4|D],}|r|jr|dk	rB|jt|�|j�qW|j�dS)a�Close all sockets associated with this context and then terminate
        the context.

        .. warning::

            destroy involves calling ``zmq_close()``, which is **NOT** threadsafe.
            If there are active sockets in other threads, this must not be called.

        Parameters
        ----------

        linger : int, optional
            If specified, set LINGER on sockets prior to closing them.
        N)r/rr�
setsockoptr	�closer)rZlingerZsockets�srrr�destroy�s
zContext.destroycCstS)N)r)rrrr�
_socket_class�szContext._socket_classcKsj|jrtt��|j||f|�}x<|jj�D].\}}y|j||�Wq*tk
rVYq*Xq*W|j|�|S)a]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.

        kwargs:
            will be passed to the __init__ method of the socket class.
        )r/rrr?r�itemsr;r8)rZsocket_typerr=�opt�valuerrrr7�s

zContext.socketcCs||j|<dS)zkset default socket options for new sockets created by this Context

        .. versionadded:: 13.0
        N)r)rrArBrrrr;�szContext.setsockoptcCs
|j|S)zkget default socket options for new sockets created by this Context

        .. versionadded:: 13.0
        )r)rrArrr�
getsockopt�szContext.getsockoptcCs$|tjkr|j||�S||j|<dS)z"set default sockopts as attributesN)rr
�setr)r�namerArBrrr�
_set_attr_opt�s
zContext._set_attr_optcCs6|tjkr|j|�S||jkr(t|��n
|j|SdS)z"get default sockopts as attributesN)rr
rr�AttributeError)rrErArrr�
_get_attr_opts




zContext._get_attr_optcCsX|j�}ytt|�}Wn tk
r6td|��YnX||jkrLt|��n|j|=dS)z%delete default sockopts as attributeszno such socket option: %sN)�upper�getattrrrGr)r�keyrArrr�__delattr__
s

zContext.__delattr__)r)N)r)N)#�__name__�
__module__�__qualname__�__doc__rr+rr0r,rrrrrr!r$�__deepcopy__�classmethodrr*r1rr5r8r:r>�propertyr?r7r;rCrFrHrL�
__classcell__rr)rrrs:		

$


r)rP�atexitr-Z	threadingr�weakrefrZzmq.backendrZContextBase�rZ	attrsettrrrr	r
r7rZ	zmq.errorrr
r�register�__all__rrrr�<module>s"