
    Ef                     f    d Z ddlmZmZmZmZ ddlZddlZddlm	Z	  G d de	j                        Z
y)zDLowest-common-denominator implementations of platform functionality.    )absolute_importdivisionprint_functionwith_statementN   )	interfacec                   4    e Zd ZdZd Zd Zd Zd Zd Zd Z	y)	WakerzCreate an OS independent asynchronous pipe.

    For use on platforms that don't have os.pipe() (or where pipes cannot
    be passed to select()), but do have sockets.  This includes Windows
    and Jython.
    c                    t        j                          | _        | j                  j                  t         j                  t         j                  d       d}	 |dz  }t        j                          }|j                  d       |j                  d       |j                         }	 | j                  j                  |       	 |j                         \  | _        }| j                  j!                  d       | j                  j!                  d       |j                          | j                  j#                         | _        y # t         j                  $ r}t        t        d      r|d   t        j                  k7  r |dk\  r?|j                          | j                  j                          t        j                  d      |j                          Y d }~nd }~ww xY w)Nr   r   )z	127.0.0.1r   WSAEADDRINUSE
   zCannot bind trigger!)socketwriter
setsockoptIPPROTO_TCPTCP_NODELAYbindlistengetsocknameconnecterrorhasattrerrnor   closeacceptreadersetblockingfileno	reader_fd)selfcountaconnect_addressdetailaddrs         K/usr/lib/python3/dist-packages/zmq/eventloop/minitornado/platform/common.py__init__zWaker.__init__   s`    mmo 	v1163E3EqIQJE AFF#$HHQKmmoO##O4$ HHJT""		++-+ << 7q	U%8%88  B;GGIKK%%' ,,'=>> 		' s   "D< <GA;GGc                 6    | j                   j                         S N)r   r   r    s    r&   r   zWaker.filenoD       {{!!##    c                 6    | j                   j                         S r)   )r   r   r*   s    r&   write_filenozWaker.write_filenoG   r+   r,   c                 z    	 | j                   j                  d       y # t        t        j                  f$ r Y y w xY w)N   x)r   sendIOErrorr   r   r*   s    r&   wakez
Waker.wakeJ   s4    	KKT"& 		s    ::c                     	 	 | j                   j                  d      }|sy # t        t        j                  f$ r Y y w xY w)Ni   )r   recvr2   r   r   )r    results     r&   consumezWaker.consumeP   sF    	))$/  & 		s   " " >>c                 l    | j                   j                          | j                  j                          y r)   )r   r   r   r*   s    r&   r   zWaker.closeY   s"    r,   N)
__name__
__module____qualname____doc__r'   r   r.   r3   r7   r    r,   r&   r
   r
   
   s&    1.f$$r,   r
   )r<   
__future__r   r   r   r   r   r    r   r
   r=   r,   r&   <module>r@      s)    J P P   QIOO Qr,   