6 """ |
6 """ |
7 Module implementing a function to patch the process creation functions to |
7 Module implementing a function to patch the process creation functions to |
8 support multiprocess debugging. |
8 support multiprocess debugging. |
9 """ |
9 """ |
10 |
10 |
|
11 import contextlib |
11 |
12 |
12 from DebugUtilities import ( |
13 from DebugUtilities import ( |
13 patchArguments, patchArgumentStringWindows, isPythonProgram, |
14 patchArguments, patchArgumentStringWindows, isPythonProgram, |
14 isWindowsPlatform |
15 isWindowsPlatform |
15 ) |
16 ) |
402 except ImportError: |
403 except ImportError: |
403 import _winapi as _subprocess |
404 import _winapi as _subprocess |
404 patchModule(_subprocess, 'CreateProcess', createCreateProcess) |
405 patchModule(_subprocess, 'CreateProcess', createCreateProcess) |
405 else: |
406 else: |
406 patchModule(os, "fork", createFork) |
407 patchModule(os, "fork", createFork) |
407 try: |
408 with contextlib.suppress(ImportError): |
408 import _posixsubprocess |
409 import _posixsubprocess |
409 patchModule(_posixsubprocess, "fork_exec", createForkExec) |
410 patchModule(_posixsubprocess, "fork_exec", createForkExec) |
410 except ImportError: |
|
411 pass |
|
412 |
411 |
413 _debugClient = debugClient |
412 _debugClient = debugClient |