a d@sdZddlZejdkredddlZddlZddlZddlZddlZddl Z ddl Z dZ dZ ej Z ejZeZdde d d d ZGd d d ZGdddejZdS)z)Various Windows specific bits and pieces.Nwin32z win32 only)pipePopenPIPE PipeHandlei F)TT)duplex overlappedbufsizec Cs$tjdtttd}|r>tj}tj tj B}||}}ntj }tj }d|}}|tj O}|drp|tj O}|drtj }nd}d} } z\t||tjd||tjtj} t||dtjtj|tj} tj| dd} | d| | fWS| durt| | durt| Yn0dS)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-{:d}-{:d}-)prefixrNTr)tempfilemktempformatosgetpidnext _mmap_counter_winapiPIPE_ACCESS_DUPLEX GENERIC_READ GENERIC_WRITEPIPE_ACCESS_INBOUNDFILE_FLAG_FIRST_PIPE_INSTANCEFILE_FLAG_OVERLAPPEDCreateNamedPipe PIPE_WAITNMPWAIT_WAIT_FOREVERNULL CreateFile OPEN_EXISTINGConnectNamedPipeGetOverlappedResult CloseHandle) rrr addressopenmodeaccessobsizeibsizeflags_and_attribsh1h2ovr--/usr/lib64/python3.9/asyncio/windows_utils.pyr sJ            rc@sbeZdZdZddZddZeddZdd Ze j d d d Z e j fd dZddZddZdS)rzWrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. cCs ||_dSN_handleselfhandler-r-r.__init__VszPipeHandle.__init__cCs2|jdurd|j}nd}d|jjd|dS)Nzhandle=closed< >)r1 __class____name__r2r-r-r.__repr__Ys zPipeHandle.__repr__cCs|jSr/r0r3r-r-r.r4`szPipeHandle.handlecCs|jdurtd|jS)NzI/O operation on closed pipe)r1 ValueErrorr=r-r-r.filenods zPipeHandle.fileno)r#cCs|jdur||jd|_dSr/r0)r3r#r-r-r.closeis  zPipeHandle.closecCs*|jdur&|d|t|d|dS)Nz unclosed )source)r1ResourceWarningr@)r3_warnr-r-r.__del__ns zPipeHandle.__del__cCs|Sr/r-r=r-r-r. __enter__sszPipeHandle.__enter__cCs |dSr/)r@)r3tvtbr-r-r.__exit__vszPipeHandle.__exit__N)r; __module__ __qualname____doc__r5r<propertyr4r?rr#r@warningswarnrDrErIr-r-r-r.rQs rcs"eZdZdZdfdd ZZS)rzReplacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. Nc s|drJ|dddks"Jd}}}d} } } |tkrbtddd\} } t| tj}n|}|tkrtdd\} } t| d}n|}|tkrtdd\} }t|d}n|tkr|}n|}zz tj |f|||d |Wn0| | | fD]}|durt |qYn>0| dur,t | |_ | dur@t | |_| durTt | |_W|tkrjt||tkr~t||tkrt|n>|tkrt||tkrt||tkrt|0dS) Nuniversal_newlinesr r)FTT)rr)TFr )stdinstdoutstderr)getrrmsvcrtopen_osfhandlerO_RDONLYSTDOUTsuperr5rr#rrQrRrSr@)r3argsrQrRrSkwds stdin_rfd stdout_wfd stderr_wfdstdin_wh stdout_rh stderr_rhstdin_rh stdout_wh stderr_whhr:r-r.r5s^                    zPopen.__init__)NNN)r;rJrKrLr5 __classcell__r-r-rfr.r}sr)rLsysplatform ImportErrorr itertoolsrUr subprocessr rN__all__BUFSIZErrXcountrrrrr-r-r-r.s$ 1,