B
    b
,c  ã               @   sZ   d Z ddlmZmZ ddlmZ ddlZddlmZ ddl	m
Z
 G dd	„ d	e
ƒZd	gZdS )
zNZAP Authenticator integrated with the tornado IOLoop.

.. versionadded:: 14.1
é    )ÚAnyÚOptional)ÚioloopN)Ú	zmqstreamé   )ÚAuthenticatorc                   sl   e Zd ZU dZejed< ejed< de	d e
ee	ej dœ‡ fdd	„Zdd
œ‡ fdd„Z‡ fdd„Z‡  ZS )ÚIOLoopAuthenticatorz0ZAP authentication for use in the tornado IOLoopÚ
zap_streamÚio_loopNúutf-8zzmq.Context)ÚcontextÚencodingÚlogr
   c                s*   t ƒ  |||¡ d | _|p"tj ¡ | _d S )N)ÚsuperÚ__init__r	   r   ÚIOLoopZcurrentr
   )Úselfr   r   r   r
   )Ú	__class__© ú.lib/python3.7/site-packages/zmq/auth/ioloop.pyr      s    zIOLoopAuthenticator.__init__)Úreturnc                s.   t ƒ  ¡  t | j| j¡| _| j | j¡ dS )zStart ZAP authenticationN)	r   Ústartr   Ú	ZMQStreamZ
zap_socketr
   r	   Zon_recvZhandle_zap_message)r   )r   r   r   r   #   s    
zIOLoopAuthenticator.startc                s$   | j r| j  ¡  d| _ tƒ  ¡  dS )zStop ZAP authenticationN)r	   Úcloser   Ústop)r   )r   r   r   r   )   s    
zIOLoopAuthenticator.stop)Nr   NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__annotations__r   r   r   Ústrr   r   r   r   Ú__classcell__r   r   )r   r   r      s   


   $r   )r   Útypingr   r   Ztornador   ZzmqZzmq.eventloopr   Úbaser   r   Ú__all__r   r   r   r   Ú<module>   s   