Your IP : 18.218.1.38


Current Path : /opt/alt/python34/lib64/python3.4/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/asyncio/__pycache__/windows_utils.cpython-34.pyo

�
j f��@sMdZddlZejdkr0ed��nddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddddd	gZd
Z
e	jZe	jZej�Zeed�r�ejZnejejddd�Zdd
ddde
dd�ZGdd	�d	�ZGdd�de	j�ZdS)z*
Various Windows specific bits and pieces
�N�win32z
win32 only�
socketpair�pipe�Popen�PIPE�
PipeHandlei c
Csq|tjkrd}n$|tjkr0d}ntd��|tjkrZtd��n|dkrutd��ntj|||�}z�|j|df�|jd�|j�dd	�\}}tj|||�}yb|jd
�y|j	||f�Wnt
tfk
rYnX|jd�|j�\}}	Wn|j
��YnXWd|j
�X||fS)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 supportedrzOnly 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Cs�tjddtj�tt�f�}|rWtj}tjtj	B}||}}ntj
}tj	}d|}}|tjO}|dr�|tjO}n|dr�tj}nd}d}	}
y�tj
||tjd||tjtj�}	tj||dtjtj|tj�}
tj|	dd�}|jd�|	|
fSWnC|	dk	rltj|	�n|
dk	r�tj|
�n�YnXdS)zELike os.pipe() but with overlapped support and using handles not fds.�prefixz\\.\pipe\python-pipe-%d-%d-rrNrT)�tempfileZmktemp�os�getpid�next�
_mmap_counter�_winapiZPIPE_ACCESS_DUPLEXZGENERIC_READZ
GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ	PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ
CreateFileZ
OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult�CloseHandle)rrrZaddressZopenmode�accessZobsizeZibsizeZflags_and_attribsZh1Zh2ZovrrrrSs@			





c@s�eZdZdZdd�Zdd�Zedd��Zdd	�Zd
e	j
dd�Zd
d�Zdd�Z
dd�ZdS)rz�Wrapper for an overlapped pipe handle which is vaguely file-object like.

    The IOCP event loop can use these instead of socket objects.
    cCs
||_dS)N)�_handle)�self�handlerrr�__init__�szPipeHandle.__init__cCs9|jdk	rd|j}nd}d|jj|fS)Nz	handle=%r�closedz<%s %s>)r#�	__class__�__name__)r$r%rrr�__repr__�szPipeHandle.__repr__cCs|jS)N)r#)r$rrrr%�szPipeHandle.handlecCs%|jdkrtd��n|jS)NzI/O operatioon on closed pipe)r#r)r$rrr�fileno�szPipeHandle.filenor!cCs,|jdk	r(||j�d|_ndS)N)r#)r$r!rrrr�s
zPipeHandle.closecCs4|jdk	r0tjd|t�|j�ndS)Nzunclosed %r)r#�warnings�warn�ResourceWarningr)r$rrr�__del__�szPipeHandle.__del__cCs|S)Nr)r$rrr�	__enter__�szPipeHandle.__enter__cCs|j�dS)N)r)r$�t�v�tbrrr�__exit__�szPipeHandle.__exit__N)r)�
__module__�__qualname__�__doc__r&r*�propertyr%r+r r!rr/r0r4rrrrr�scs1eZdZdZddd�fdd�Z�S)rz�Replacement for subprocess.Popen using overlapped pipe handles.

    The stdin, stdout, stderr are None or instances of PipeHandle.
    Ncsd}}}d}	}
}|tkr[tdd	dd�\}}	tj|tj�}n|}|tkr�tdd
�\}
}
tj|
d�}n|}|tkr�tdd�\}}tj|d�}n|tkr�|}n|}z�y)t�j|d|d|d||�WnAx3|	|
|fD]"}|dk	r0t	j
|�q0q0W�Yn[X|	dk	r|t|	�|_n|
dk	r�t|
�|_
n|dk	r�t|�|_nWd|tkr�tj|�n|tkr�tj|�n|tkrtj|�nXdS)NrFTrr�stdin�stdout�stderr)FT)TF)TF)rr�msvcrtZopen_osfhandler�O_RDONLY�STDOUT�superr&r r!rr9r:r;r)r$�argsr9r:r;�kwdsZ	stdin_rfdZ
stdout_wfdZ
stderr_wfdZstdin_whZ	stdout_rhZ	stderr_rhZstdin_rhZ	stdout_whZ	stderr_wh�h)r(rrr&�sH	zPopen.__init__)r)r5r6r7r&rr)r(rr�s)TT)r7�sys�platform�ImportErrorr �	itertoolsr<rr
�
subprocessrr,�__all__ZBUFSIZErr>�countr�hasattrrrr
rrrrrrr�<module>s,		.0,

?>