File: //lib64/python3.6/asyncio/__pycache__/windows_utils.cpython-36.opt-1.pyc
3
\ @ s d Z ddlZejdkredddlZddlZddlZddlZddlZddl Z ddl
Z
ddlZddddd gZd
Z
e jZe jZej ZeedrejZnejejdfddZdde
dddZG dd d ZG dd de jZdS )z*
Various Windows specific bits and pieces
NZwin32z
win32 only
socketpairpipePopenPIPE
PipeHandlei c
C s | t jkrd}n| t jkr d}ntd|t jkr:td|dkrJtdt j | ||}z|j|df |jd |j dd \}}t j | ||}yP|jd
y|j ||f W n t
tfk
r Y nX |jd |j \}} W n |j
Y nX W d|j
X ||fS )zA 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)socketAF_INETZAF_INET6
ValueErrorSOCK_STREAMZbindZlistenZgetsocknameZsetblockingZconnectBlockingIOErrorInterruptedErrorZacceptclose)
ZfamilytypeprotohostZlsockZaddrZportZcsockZssock_ r -/usr/lib64/python3.6/asyncio/windows_utils.pyr % s8
FT)duplex
overlappedbufsizec C s" t jdtj ttf d}| r>tj}tjtj B }|| }}ntj
}tj }d| }}|tjO }|d rp|tjO }|d rtj}nd}d } }
yZtj
||tjd||tjtj} tj||dtjtj|tj}
tj| dd}|jd | |
fS | dk rtj| |
dk rtj|
Y nX dS )zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-%d-%d-)prefixr r NT)r )tempfileZmktemposgetpidnext
_mmap_counter_winapiZPIPE_ACCESS_DUPLEXZGENERIC_READZ
GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ
CreateFileZ
OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResultCloseHandle)r r r ZaddressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2Zovr r r r S s@
c @ s\ e Zd ZdZdd Zdd Zedd Zdd Ze j
d
ddZd
d Zdd Z
dd ZdS )r zWrapper 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)selfhandler r r __init__ s zPipeHandle.__init__c C s* | j d k rd| j }nd}d| jj|f S )Nz handle=%rclosedz<%s %s>)r"