HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/zmq/sugar/__pycache__/context.cpython-310.pyc
o

�N�gM*�@s�dZddlZddlZddlZddlmZddlmZmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZddlmZmZmZddlmZd	d
lmZmZd	dlmZdaddd�Ze� e�e
ddd�Z!e
dddd�Z"Gdd�deee	e"�ZdgZ#dS)zPython bindings for 0MQ.�N)�Lock)�Any�Dict�Generic�List�Optional�Type�TypeVar)�WeakSet)�Context)�
ContextOption�Errno�SocketOption)�ZMQError�)�AttributeSetter�OptValT)�SocketF�returncCsdadS)NT)�_exiting�rr�E/opt/saltstack/salt/lib/python3.10/site-packages/zmq/sugar/context.py�_notice_atexitsr�Tr)�bound�STrT)rZ	covariantc	s$eZdZUdZeeefed<dZeed<e	�Z
dZeeed<dZ
eed<eZeeed<dFd
dded
eddf�fdd�
ZdGdd�ZdZdefdd�Zd
edefdd�Zdedededdfdd�ZdHd
ededefdd�ZeZed eed!edefd"d#��Zed eed$edefd%d&��ZedFd eededefd'd(��Z dG�fd)d*�Z!de"efd+d,�Z#d-eddfd.d/�Z$d-eddfd0d1�Z%dHd2ee&ddfd3d4�Z'd
ed5ed
edefd6d7�Z(d8ed9eddfd:d;�Z)d8ede*fd<d=�Z+d>ed8ed9e*ddfd?d@�Z,d>ed8ede*fdAdB�Z-dCeddfdDdE�Z.�Z/S)Irz[Create a zmq Context

    A zmq Context creates sockets via its ``ctx.socket`` method.
    �sockoptsN�	_instance�
_instance_pidF�_sockets�
_socket_classr�selfzContext[Socket]�
io_threads�kwargsrcsBt�jdd|i|��|�dd�rd|_nd|_i|_t�|_dS)Nr"�shadowFTr)�super�__init__�get�_shadowrr
r)r!r"r#��	__class__rrr&2szContext.__init__cCsFt�|jsts|js!tjd|��td|d�|��dSdSdSdS)zMdeleting a Context should terminate it, without trying non-threadsafe destroyzunclosed context �)�
stacklevel�sourceN)�localsr(r�closed�warnings�warn�ResourceWarning�term�r!rrr�__del__;s��zContext.__del__zzmq.ContextcCs�|j}|j�dd�}|dur|j�d|j��}|jrdnd}t|dd�r9t|j�}|dkr/dnd}|�d|��}nd}d	|�d
|�dt	t
|���|�d�S)
N�	_repr_cls�.z closed�rr�sz socket�<�(z) at �>)r*�__dict__r'�
__module__�__name__r/�getattr�lenr�hex�id)r!�clsr6r/Z	n_socketsr9�socketsrrr�__repr__Ls
$zContext.__repr__cCs|S�Nrr4rrr�	__enter__\szContext.__enter__�exc_type�	exc_value�	tracebackcCs|��dSrG)r3)r!rIrJrKrrr�__exit___szContext.__exit__�memocCs|j�|j�S)z'Copying a Context creates a shadow copy)r*r$�
underlying)r!rMrrr�__copy__bszContext.__copy__rD�addresscCsddlm}||�}||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.interoprR)rDrPrRrrrr$hs	
zContext.shadow�ctxcCs4ddlm}ddlm}|�|�}||�}||d�S)zuShadow an existing pyczmq context

        ctx is the FFI `zctx_t *` pointer

        .. versionadded:: 14.1
        r)�zctxrQrS)ZpyczmqrVrTrRrN)rDrUrVrRrNrPrrr�
shadow_pyczmqvs


zContext.shadow_pyczmqcCs�|jdus|jt��ks|jjrI|j�.|jdus$|jt��ks$|jjr8||d�|_t��|_Wd�|jSWd�|jS1sDwY|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")rr�os�getpidr/�_instance_lock)rDr"rrr�instance�s$
�
�
��
��zContext.instancecst���dS)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.
        N)r%r3r4r)rrr3�szContext.termcCst|j�}|�tj�|SrG)�dirr*�extendr�__members__)r!�keysrrr�__dir__�s
zContext.__dir__�socketcCs|j�|�dS)zBAdd a weakref to a socket for Context.destroy / reference countingN)r�add�r!rarrr�_add_socket�szContext._add_socketcCs$t|dd�dur|j�|�dSdS)z8Remove a socket for Context.destroy / reference countingrN)r@r�discardrcrrr�
_rm_socket�s�zContext._rm_socket�lingercCsV|jrdS|j}t�|_|D]}|r$|js$|dur |�tj|�|��q|��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
�
setsockoptrZLINGER�closer3)r!rgrEr9rrr�destroy�s
�zContext.destroy�socket_typec	Ksh|jrttj��|j||fi|��}|j��D]\}}z|�||�Wqty,Yqw|�|�|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/rr
�ENOTSUPr r�itemsrhrd)r!rkr#r9�opt�valuerrrra�s
���
zContext.socketrnrocCs||j|<dS)zkset default socket options for new sockets created by this Context

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

        .. versionadded:: 13.0
        rp)r!rnrrr�
getsockopts
zContext.getsockopt�namecCs<|tjvr|�||�S|tjvr||j|<dStd|����)z"set default sockopts as attributesz"No such context or socket option: N)rr^�setrr�AttributeError)r!rrrnrorrr�
_set_attr_opts


zContext._set_attr_optcCs0|tjvr
|�|�S||jvrt|��|j|S)z"get default sockopts as attributes)rr^r'rrt)r!rrrnrrr�
_get_attr_opt(s




zContext._get_attr_opt�keycCsR|��}ztt|�}Wntytd|����w||jvr#t|��|j|=dS)z%delete default sockopts as attributeszNo such socket option: N)�upperr@rrtr)r!rwrnrrr�__delattr__2s�
zContext.__delattr__)r�rNrG)0r?r>�__qualname__�__doc__r�intr�__annotations__rrrZrrr(r
rr rrr&r5r6�strrFrrHrLrO�__deepcopy__�classmethodr$rWr[r3rr`rdrf�floatrjrarhrrqrurvry�
__classcell__rrr)rr#sD
 
	
$		
rz)$r|�atexitrXr0�	threadingr�typingrrrrrrr	�weakrefr
Zzmq.backendrZContextBaseZ
zmq.constantsrr
rZ	zmq.errorrZ	attrsettrrrrarrr�registerrr�__all__rrrr�<module>s*$