403Webshell
Server IP : 198.38.94.13  /  Your IP : 216.73.217.33
Web Server : Apache
System : Linux d4744.dxb1.stableserver.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : revivere ( 1140)
PHP Version : 8.2.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/saltstack/salt/lib/python3.10/site-packages/zmq/sugar/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/saltstack/salt/lib/python3.10/site-packages/zmq/sugar/__pycache__/context.cpython-310.pyc
o

;j�8�@s4UdZddlmZddlZddlZddlmZddlmZm	Z	m
Z
mZmZddl
mZddlmZddlZddlmZdd	lmZdd
lmZmZmZddlmZddlmZd
dlm Z m!Z!d
dl"m#Z#m$Z$da%ddd�Z&e�'e&�eddd�Z(edddd�Z)Gdd�dee e
e)�Zee$Z*de+d<ddgZ,dS) zPython bindings for 0MQ.�)�annotationsN)�Lock)�Any�Callable�Generic�TypeVar�overload)�warn)�WeakSet)�	TypeAlias)�Context)�
ContextOption�Errno�SocketOption)�ZMQError��
cast_int_addr�)�AttributeSetter�OptValT)�Socket�
SyncSocketF�return�NonecCsdadS�NT)�_exiting�rr�E/opt/saltstack/salt/lib/python3.10/site-packages/zmq/sugar/context.py�_notice_atexitsr�_ContextTyper)�bound�_SocketTyperT)r �	covariantcs|eZdZUdZded<dZded<e�ZdZded<d	Z	dZ
d	Zd
ed<eZ
ded
<ed]d^dd��Zed_dd��Zed`dd��Z		dadb�fdd�
Zdcdd�Zd Zddd"d#�Zded%d&�Zdfd*d+�Zdgdhd-d.�ZeZedid3d4��Zedjd6d7��Zed]dkd8d9��Zdc�fd:d;�Zdld=d>�Zdmd@dA�ZdmdBdC�ZdgdndEdF�Z	dgdodLdM�Z dpdPdQ�Z!dqdSdT�Z"drdVdW�Z#dsdXdY�Z$dtd[d\�Z%�Z&S)ura�Create a zmq Context

    A zmq Context creates sockets via its ``ctx.socket`` method.

    .. versionchanged:: 24

        When using a Context as a context manager (``with zmq.Context()``),
        or deleting a context without closing it first,
        ``ctx.destroy()`` is called,
        closing any leftover sockets,
        instead of `ctx.term()` which requires sockets to be closed first.

        This prevents hangs caused by `ctx.term()` if sockets are left open,
        but means that unclean destruction of contexts
        (with sockets left open) is not safe
        if sockets are managed in other threads.

    .. versionadded:: 25

        Contexts can now be shadowed by passing another Context.
        This helps in creating an async copy of a sync context or vice versa::

            ctx = zmq.Context(async_ctx)

        Which previously had to be::

            ctx = zmq.Context.shadow(async_ctx.underlying)
    zdict[int, Any]�sockoptsNr�	_instance�
int | None�
_instance_pidFr
�_socketsztype[_SocketType]�
_socket_classr�self�SyncContext�
io_threads�intcC�dS�Nr�r)r+rrr�__init__Q�zContext.__init__cCr-r.rr/rrrr0Tr1�shadow�
Context | intcCr-r.r)r)r2rrrr0Wr1r�
int | Contextrrcs�t|t�r	|}d}d}|r,d|_||_t|t�s'z|j}Wn	ty&Ynwt|�}nd|_t�j	||d�i|_
t�|_dS)NrrTF)r+r2)
�
isinstancer�_shadow�_shadow_objr,�
underlying�AttributeErrorr�superr0r#r
r')r)r+r2Zshadow_address��	__class__rrr0Zs$


�
cCsbt�|js+ts-|js/d|_tdur%t|dd�dur%td|��td|d�|��dSdSdSdS)a)Deleting a Context without closing it destroys it and all sockets.

        .. versionchanged:: 24
            Switch from threadsafe `term()` which hangs in the event of open sockets
            to less safe `destroy()` which
            warns about any leftover sockets and closes them.
        TNr'zUnclosed context ���
stacklevel�source)	�localsr6r�closed�_warn_destroy_closer	�getattr�ResourceWarning�destroy�r)rrr�__del__vs
��zContext.__del__zzmq.Context�strcCs�|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�r'r�sz socket�<�(z) at �>)r<�__dict__�get�
__module__�__name__rBrD�lenr'�hex�id)r)�clsrJrBZ	n_socketsrM�socketsrrr�__repr__�s
$zContext.__repr__rcCs|Sr.rrGrrr�	__enter__�r1zContext.__enter__�exc_type�	exc_value�	tracebackcCsd|_|��dSr)rCrF)r)r\r]r^rrr�__exit__�szContext.__exit__�memocCs|j�|j�S)z'Copying a Context creates a shadow copy)r<r2r8)r)r`rrr�__copy__�szContext.__copy__rX�type[_ContextType]�address�int | zmq.ContextcCs
||d�S)aIShadow an existing libzmq context

        address is a zmq.Context or an integer (or FFI pointer)
        representing the address of the libzmq context.

        .. versionadded:: 14.1

        .. versionadded:: 25
            Support for shadowing `zmq.Context` objects,
            instead of just integer addresses.
        �r2r)rXrcrrrr2�s

zContext.shadow�ctxcCs4ddlm}ddlm}|�|�}||�}||d�S)zuShadow an existing pyczmq context

        ctx is the FFI `zctx_t *` pointer

        .. versionadded:: 14.1
        r)�zctxrre)Zpyczmqrg�zmq.utils.interoprr8)rXrfrgrr8rcrrr�
shadow_pyczmq�s


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-process 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+)r$r&�os�getpidrB�_instance_lock)rXr+rrr�instance�s$
�
�
��
��zContext.instancecst���dS)a�Close 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,
        in which case you may see a ResourceWarning about the unclosed context.
        N)r:�termrGr;rrrn�szContext.term�	list[str]cCst|j�}|�tj�|Sr.)�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)rurrr�_add_socketszContext._add_socketcCs$t|dd�dur|j�|�dSdS)z8Remove a socket for Context.destroy / reference countingr'N)rDr'�discardrwrrr�
_rm_sockets�zContext._rm_socket�lingercCs�|jrdStt|dd�p
g�}|D](}|r9|js9|jr*tdur*td|��td|d�|dur5|�tj|�|�	�q|�
�dS)a�Close all sockets associated with this context and then terminate
        the context.

        .. warning::

            destroy involves calling :meth:`Socket.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.
        Nr'z(Destroying context with unclosed socket �r>)rB�listrDrCr	rE�
setsockoptrZLINGER�closern)r)r{rYrMrrrrF!s"
��zContext.destroy�socket_type�socket_class�1Callable[[_ContextType, int], _SocketType] | None�kwargsr!c	Kst|jrttj��|dur|j}|||fi|��}|j��D]\}}z|�||�Wqty2Yqw|�|�|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.

        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.

            .. versionadded:: 25

        kwargs:
            will be passed to the __init__ method of the socket class.
        N)	rBrr�ENOTSUPr(r#�itemsr~rx)r)r�r�r�rM�opt�valuerrrruDs$
����
zContext.socketr�r�cCs||j|<dS)zkset default socket options for new sockets created by this Context

        .. versionadded:: 13.0
        N�r#)r)r�r�rrrr~oszContext.setsockoptrcCs
|j|S)zkget default socket options for new sockets created by this Context

        .. versionadded:: 13.0
        r�)r)r�rrr�
getsockoptvs
zContext.getsockopt�namecCs<|tjvr|�||�S|tjvr||j|<dStd|����)z"set default sockopts as attributesz"No such context or socket option: N)r
rr�setrr#r9)r)r�r�r�rrr�
_set_attr_opt}s


zContext._set_attr_optcCs0|tjvr
|�|�S||jvrt|��|j|S)z"get default sockopts as attributes)r
rrrRr#r9)r)r�r�rrr�
_get_attr_opt�s




zContext._get_attr_opt�keycCsl||jvr
|j�|�dS|��}ztt|�}Wnty&td|����w||jvr0t|��|j|=dS)z%delete default sockopts as attributesNzNo such socket option: )rQ�pop�upperrDrr9r#)r)r�r�rrr�__delattr__�s
�
zContext.__delattr__)r)r)r*r+r,)r)r*r+r)r)r*r2r3)rr)r)r*r+r4r2r3rr�rr)rrI)r)rrr)r\rr]rr^rrrr.)r)rr`rrr)rXrbrcrdrr)rXrbrfrrr)rXrbr+r,rr)rro)rurrr)r{r%rr)
r)rr�r,r�r�r�rrr!)r�r,r�rrr)r�r,rr)r�rIr�r,r�rrr)r�rIr�r,rr)r�rIrr)'rTrS�__qualname__�__doc__�__annotations__r$rrlr&r6r7rCrr(rr0rHrJrZr[r_ra�__deepcopy__�classmethodr2rirmrnrtrxrzrFrur~r�r�r�r��
__classcell__rrr;rr(sZ
�



$

	
&�
+


	
rr*r�)-r��
__future__r�atexitrj�	threadingr�typingrrrrr�warningsr	�weakrefr
ZzmqZzmq._typingrZzmq.backendrZContextBaseZ
zmq.constantsr
rrZ	zmq.errorrrhrZ	attrsettrrrrurrrr�registerrr!r*r��__all__rrrr�<module>s4

{

Youez - 2016 - github.com/yon3zu
LinuXploit