[ @sddlZddlZddlZddlZddlZddlmZddlmZddlmZddlm Z dgZ dZ ej d koe ed d Zejjjd ZGd ddeZdS)N)context)spawn) reduction)utilPopeniZwin32frozenFzpythonservice.exec@s[eZdZdZdZddZddZddd Zd d Zd d Z dS)rz@ Start a subprocess to run the code of a process object rc Cstj|j}tjdd\}}tj|d}tjdtj d|}dj dd|D}t |ddd }yJtj tj |ddd dddd \}} } } tj| Wntj|YnX| |_d|_||_t||_tj|tj|jftj|z$tj||tj||WdtjdXWdQXdS) NrZ parent_pidZ pipe_handle css|]}d|VqdS)z"%s"N).0xr r 7/usr/lib/python3.4/multiprocessing/popen_spawn_win32.py *sz!Popen.__init__..wbclosefdTF)rZget_preparation_data_name_winapiZ CreatePipemsvcrtZopen_osfhandleZget_command_lineosgetpidjoinopenZ CreateProcessZget_executableZ CloseHandlepid returncode_handleintsentinelrZFinalizerZset_spawning_popenrdump) selfZ process_objZ prep_dataZrhandleZwhandleZwfdcmdZto_childZhpZhtrtidr r r __init__!s2  '     zPopen.__init__cCs+|tjksttj||jS)N)rZget_spawning_popenAssertionErrorrZ duplicater)rZhandler r r duplicate_for_childFszPopen.duplicate_for_childNcCs|jdkr|dkr'tj}ntdt|dd}tjt|j|}|tjkrtj|j}|t krt j }n||_qn|jS)Nrig?) rrZINFINITEmaxrZWaitForSingleObjectrZ WAIT_OBJECT_0ZGetExitCodeProcess TERMINATEsignalSIGTERM)rtimeoutZmsecsZrescoder r r waitJs    z Popen.waitcCs|jddS)Nr(r)r*)rr r r pollZsz Popen.pollc Csf|jdkrbytjt|jtWqbtk r^|jdddkrZnYqbXndS)Nr(g?)rrZTerminateProcessrrr%OSErrorr*)rr r r terminate]s  zPopen.terminate) __name__ __module__ __qualname____doc__methodr!r#r*r+r-r r r r rs  %  )rrr&sysrrrrr__all__r%platformgetattrZWINEXE executablelowerendswithZ WINSERVICEobjectrr r r r s      !