U g@sddlZddlZddlZddlZddlZddlmZmZmZddl m Z ddl m Z dgZ dZ ejdkoreed d Zejd Zd d Zeejej ZddZGdddeZdS)N) reductionget_spawning_popenset_spawning_popen)spawn)utilPopeniZwin32frozenFzpythonservice.execCs ||kptj|tj|kSN)ospathnormcase)Zp1Zp2r7/usr/lib/python3.8/multiprocessing/popen_spawn_win32.py_path_eqsrcGs|D]}t|qdSr )_winapi CloseHandle)Zhandleshandlerrr_close_handlessrc@sJeZdZdZdZddZddZddd Zd d Zd d Z e Z ddZ dS)rz@ Start a subprocess to run the code of a process object rc CsTt|j}tdd\}}t|d}tjt |d}d dd|D}t }t rt |tjrtj}tj}tj|d<nd}t|ddd } z0t||ddd d|dd \} } } } t| Wnt|YnX| |_d|_| |_t| |_t|t|jt|f|_t|zt !|| t !|| W5tdXW5QRXdS) Nr)Z parent_pidZ pipe_handle css|]}d|VqdS)z"%s"Nr).0xrrr 9sz!Popen.__init__..Z__PYVENV_LAUNCHER__wbT)closefdF)"rZget_preparation_data_namerZ CreatePipemsvcrtZopen_osfhandleZget_command_liner getpidjoinZget_executableWINENVrsys executable_base_executableenvironcopyopenZ CreateProcessrpid returncode_handleintsentinelrZFinalizer finalizerrrdump)selfZ process_objZ prep_dataZrhandleZwhandleZwfdcmdZ python_exeenvZto_childZhpZhtr&tidrrr__init__,sT          zPopen.__init__cCs|tkstt||jSr )rAssertionErrorrZ duplicater*)r-rrrrduplicate_for_childaszPopen.duplicate_for_childNcCst|jdkrn|dkrtj}ntdt|dd}tt|j|}|tjkrnt|j}|t krht j }||_|jS)Nrig?) r'rZINFINITEmaxr)ZWaitForSingleObjectr(Z WAIT_OBJECT_0ZGetExitCodeProcess TERMINATEsignalSIGTERM)r-timeoutZmsecsrescoderrrwaites   z Popen.waitcCs |jddS)Nrr8)r;r-rrrpollusz Popen.pollcCsL|jdkrHztt|jtWn&tk rF|jdddkrBYnXdS)Ng?r<)r'rZTerminateProcessr)r(r5OSErrorr;r=rrr terminatexs  zPopen.terminatecCs |dSr )r+r=rrrclosesz Popen.close)N) __name__ __module__ __qualname____doc__methodr1r3r;r>r@killrArrrrr&s5 )r rr6r rcontextrrrrr__all__r5platformgetattrZWINEXEr!lowerendswithZ WINSERVICErr"rrobjectrrrrrs