o
    ªZh»  ã                   @  sÊ   d Z ddlmZ ddlmZ G dd„ deƒZG dd„ deƒZG dd	„ d	eƒZG d
d„ deƒZ	G dd„ deƒZ
G dd„ deƒZG dd„ deeƒZd dd„ZdadaG dd„ deƒZ	d!d"dd„Zg d¢ZdS )#z 0MQ Error classes and functions.é    )Úannotations)ÚEINTRc                   @  ó   e Zd ZdZdS )ÚZMQBaseErrorz.Base exception class for 0MQ errors in Python.N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   ú@/var/www/html/lang_env/lib/python3.10/site-packages/zmq/error.pyr   
   ó    r   c                   @  s>   e Zd ZU dZdZded< dddd„Zddd„Zddd„ZdS )ÚZMQErrorzàWrap an errno style error.

    Parameters
    ----------
    errno : int
        The ZMQ errno or None.  If None, then ``zmq_errno()`` is called and
        used.
    msg : str
        Description of the error or None.
    Nú
int | NoneÚerrnoÚmsgú
str | Nonec                 C  sn   ddl m}m} |du r|ƒ }t|tƒr'|| _|du r"||ƒ| _dS || _dS |du r2t|ƒ| _dS || _dS )a  Wrap an errno style error.

        Parameters
        ----------
        errno : int
            The ZMQ errno or None.  If None, then ``zmq_errno()`` is called and
            used.
        msg : string
            Description of the error or None.
        r   )ÚstrerrorÚ	zmq_errnoN)Úzmq.backendr   r   Ú
isinstanceÚintr   Ústr)Úselfr   r   r   r   r   r   r   Ú__init__   s   


zZMQError.__init__Úreturnr   c                 C  s   | j S ©N)r   ©r   r   r   r   Ú__str__<   s   zZMQError.__str__c                 C  s   | j j› dt| ƒ› dS )Nz('ú'))Ú	__class__r   r   r   r   r   r   Ú__repr__?   s   zZMQError.__repr__)NN)r   r   r   r   )r   r   )	r   r   r	   r
   r   Ú__annotations__r   r   r!   r   r   r   r   r      s   
 
 r   c                   @  r   )ÚZMQBindErrorznAn error for ``Socket.bind_to_random_port()``.

    See Also
    --------
    .Socket.bind_to_random_port
    Nr   r   r   r   r   r#   C   r   r#   c                   @  r   )ÚNotDonez°Raised when timeout is reached while waiting for 0MQ to finish with a Message

    See Also
    --------
    .MessageTracker.wait : object for tracking when ZeroMQ is done
    Nr   r   r   r   r   r$   L   r   r$   c                      ó"   e Zd ZdZd‡ fdd„	Z‡  ZS )ÚContextTerminatedz6Wrapper for zmq.ETERM

    .. versionadded:: 13.0
    Úignoredc                   ó   ddl m} tƒ  |¡ d S )Nr   )ÚETERM)Úzmqr)   Úsuperr   )r   r   r   r)   ©r    r   r   r   [   ó   zContextTerminated.__init__©r'   r'   ©r   r   r	   r
   r   Ú__classcell__r   r   r,   r   r&   U   ó    r&   c                      r%   )ÚAgainz7Wrapper for zmq.EAGAIN

    .. versionadded:: 13.0
    r'   c                   r(   )Nr   )ÚEAGAIN)r*   r3   r+   r   )r   r   r   r3   r,   r   r   r   g   r-   zAgain.__init__r.   r/   r   r   r,   r   r2   a   r1   r2   c                      s2   e Zd ZdZeZd‡ fdd„	Z‡ fdd„Z‡  ZS )ÚInterruptedSystemCallz¥Wrapper for EINTR

    This exception should be caught internally in pyzmq
    to retry system calls, and not propagate to the user.

    .. versionadded:: 14.7
    r'   c                   s   t ƒ  t¡ d S r   )r+   r   r   )r   r   r   r,   r   r   r   x   ó   zInterruptedSystemCall.__init__c                   s   t ƒ  ¡ }|d S )NzB: This call should have been retried. Please report this to pyzmq.)r+   r   )r   Úsr,   r   r   r   {   s   
zInterruptedSystemCall.__str__r.   )	r   r   r	   r
   r   r   r   r   r0   r   r   r,   r   r4   m   s
    r4   NTc                 C  s~   | dkr=|du rddl m} |ƒ }|dkr|sdS ddlm}m} |tkr)t|ƒ‚||kr1t|ƒ‚||kr9t|ƒ‚t	|ƒ‚dS )zhinternal utility for checking zmq return condition

    and raising the appropriate Exception class
    éÿÿÿÿNr   )r   )r3   r)   )
r   r   r*   r3   r)   r   r4   r2   r&   r   )Úrcr   Zerror_without_errnor   r3   r)   r   r   r   Ú	_check_rc€   s   ðr9   c                   @  s0   e Zd ZdZdZdddd„Zd	d
„ Zdd„ ZdS )ÚZMQVersionErrorzgRaised when a feature is not provided by the linked version of libzmq.

    .. versionadded:: 14.2
    NÚFeatureÚmin_versionr   r   c                 C  s0   t d u rddlm} |ƒ a || _|| _t | _d S )Nr   )Úzmq_version)Ú_zmq_versionr*   r=   r   r<   Úversion)r   r<   r   r=   r   r   r   r   ¤   s   
zZMQVersionError.__init__c                 C  s   dt | ƒ› dS )NzZMQVersionError('r   ©r   r   r   r   r   r!   ®   r5   zZMQVersionError.__repr__c                 C  s   | j › d| j› d| j› S )Nz requires libzmq >= z, have )r   r<   r?   r   r   r   r   r   ±   s   zZMQVersionError.__str__©r;   )r<   r   r   r   )r   r   r	   r
   r<   r   r!   r   r   r   r   r   r:   œ   s    
r:   r;   Úmin_version_infoú3tuple[int] | tuple[int, int] | tuple[int, int, int]r   r   c                 C  sD   t du rddlm} |ƒ a t | k r d dd„ | D ƒ¡}t||ƒ‚dS )zÇCheck for libzmq

    raises ZMQVersionError if current zmq version is not at least min_version

    min_version_info is a tuple of integers, and will be compared against zmq.zmq_version_info().
    Nr   )Úzmq_version_infoÚ.c                 s  s    | ]}t |ƒV  qd S r   r@   )Ú.0Úvr   r   r   Ú	<genexpr>Å   s   € z!_check_version.<locals>.<genexpr>)Ú_zmq_version_infor*   rD   Újoinr:   )rB   r   rD   r<   r   r   r   Ú_check_versionµ   s   
þrK   )r   r#   r   r$   r&   r4   r2   r:   )NTrA   )rB   rC   r   r   )r
   Ú
__future__r   r   r   Ú	Exceptionr   r   r#   r$   r&   r2   ÚInterruptedErrorr4   r9   rI   r>   ÚNotImplementedErrorr:   rK   Ú__all__r   r   r   r   Ú<module>   s"    5		
þ