Your IP : 3.143.237.54
�
j f� � @ sM d Z d d l Z e j d k r0 e d � � n d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l
Z
d d l Z d d d d d g Z d
Z
e j Z e j Z e j � Z e e d � r� e j Z n e j e j d d d � Z d d
d d d e
d d � Z Gd d � d � Z Gd d � d e j � Z d S)z*
Various Windows specific bits and pieces
� N�win32z
win32 only�
socketpair�pipe�Popen�PIPE�
PipeHandlei c
C sq | t j k r d } n$ | t j k r0 d } n t d � � | t j k rZ t d � � n | d k ru t d � � n t j | | | � } z� | j | d f � | j d � | j � d d � \ } } t j | | | � } yb | j d
� y | j | | f � Wn t
t f k
rYn X| j d � | j � \ } } Wn | j
� � Yn XWd | j
� X| | f S)z�A socket pair usable as a self-pipe, for Windows.
Origin: https://gist.github.com/4325783, by Geert Jansen.
Public domain.
z 127.0.0.1z::1z?Only AF_INET and AF_INET6 socket address families are supportedz)Only SOCK_STREAM socket type is supportedr zOnly protocol zero is supported� N� FT)�socket�AF_INETZAF_INET6�
ValueError�SOCK_STREAMZbindZlistenZgetsocknameZsetblockingZconnect�BlockingIOError�InterruptedErrorZaccept�close)
Zfamily�type�proto�hostZlsockZaddrZportZcsockZssock�_� r �:/opt/alt/python34/lib64/python3.4/asyncio/windows_utils.pyr % s8
�duplexF�
overlappedT�bufsizec C s� t j d d t j � t t � f � } | rW t j } t j t j B} | | } } n t j
} t j } d | } } | t j O} | d r� | t j O} n | d r� t j } n d } d } }
y� t j
| | t j d | | t j t j � } t j | | d t j t j | t j � }
t j | d d �} | j d � | |
f SWnC | d k rlt j | � n |
d k r�t j |
� n � Yn Xd S)zELike os.pipe() but with overlapped support and using handles not fds.�prefixz\\.\pipe\python-pipe-%d-%d-r r Nr T)�tempfileZmktemp�os�getpid�next�
_mmap_counter�_winapiZPIPE_ACCESS_DUPLEXZGENERIC_READZ
GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ
CreateFileZ
OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult�CloseHandle)r r r ZaddressZopenmode�accessZobsizeZibsizeZflags_and_attribsZh1Zh2Zovr r r r S s@
c @ s� e Z d Z d Z d d � Z d d � Z e d d � � Z d d � Z d
e j
d d � Z d
d � Z d d � Z
d d � Z d S)r z�Wrapper for an overlapped pipe handle which is vaguely file-object like.
The IOCP event loop can use these instead of socket objects.
c C s
| | _ d S)N)�_handle)�self�handler r r �__init__� s zPipeHandle.__init__c C s9 | j d k r d | j } n d } d | j j | f S)Nz handle=%r�closedz<%s %s>)r# � __class__�__name__)r$ r% r r r �__repr__� s zPipeHandle.__repr__c C s | j S)N)r# )r$ r r r r% � s zPipeHandle.handlec C s% | j d k r t d � � n | j S)NzI/O operatioon on closed pipe)r# r )r$ r r r �fileno� s zPipeHandle.filenor! c C s, | j d k r( | | j � d | _ n d S)N)r# )r$ r! r r r r � s
zPipeHandle.closec C s4 | j d k r0 t j d | t � | j � n d S)Nzunclosed %r)r# �warnings�warn�ResourceWarningr )r$ r r r �__del__� s zPipeHandle.__del__c C s | S)Nr )r$ r r r � __enter__� s zPipeHandle.__enter__c C s | j � d S)N)r )r$ �t�v�tbr r r �__exit__� s zPipeHandle.__exit__N)r) �
__module__�__qualname__�__doc__r&