a
    ވax                     @   sV   d Z ddlmZmZ ddlmZmZmZ ddl	m
Z
mZmZ G dd deZdgZdS )	zzmq Context class   )libffi)EINVAL
IO_THREADSLINGER    )ZMQErrorInterruptedSystemCall	_check_rcc                   @   sV   e Zd ZdZdZdZdZdddZedd Z	edd	 Z
d
d Zdd Zdd ZdS )ContextNFr   c                 C   sp   |rt d|| _d| _n d| _|dks0ttt | _| jt jkrRtt	 |sft
| jt| d| _d S )Nzvoid *TFr   )r   cast_zmq_ctx_shadowr   r   CZzmq_ctx_newZNULLZ	zmq_errnozmq_ctx_setr   _closed)selfZ
io_threadsZshadow r   7lib/python3.9/site-packages/zmq/backend/cffi/context.py__init__   s    
zContext.__init__c                 C   s   t td| jS )z,The address of the underlying libzmq contextZsize_t)intr   r   r   r   r   r   r   
underlying%   s    zContext.underlyingc                 C   s   | j S )N)r   r   r   r   r   closed*   s    zContext.closedc                 C   s   t | j||}t| dS )z6set a context option

        see zmq_ctx_set
        N)r   r   r   r
   )r   optionvaluercr   r   r   set.   s    zContext.setc                 C   s   t | j|}t|dd |S )z4get context option

        see zmq_ctx_get
        F)Zerror_without_errno)r   Zzmq_ctx_getr   r
   )r   r   r   r   r   r   get6   s    zContext.getc                 C   sF   | j r
d S t| j}zt| W n ty4   Y n0 d | _d| _d S )NT)r   r   Zzmq_ctx_destroyr   r
   r	   r   )r   r   r   r   r   term?   s    zContext.term)r   N)__name__
__module____qualname__r   Z
_iothreadsr   r   r   propertyr   r   r   r   r   r   r   r   r   r      s   


	r   N)__doc__Z_cffir   r   r   Z	constantsr   r   r   Z	zmq.errorr   r	   r
   objectr   __all__r   r   r   r   <module>   s
   A