eric6/DebugClients/Python/MultiProcessDebugExtension.py

branch
maintenance
changeset 8273
698ae46f40a4
parent 8243
cc717c2ae956
--- a/eric6/DebugClients/Python/MultiProcessDebugExtension.py	Fri Apr 02 11:59:41 2021 +0200
+++ b/eric6/DebugClients/Python/MultiProcessDebugExtension.py	Sat May 01 14:27:20 2021 +0200
@@ -8,6 +8,7 @@
 support multiprocess debugging.
 """
 
+import contextlib
 
 from DebugUtilities import (
     patchArguments, patchArgumentStringWindows, isPythonProgram,
@@ -306,20 +307,23 @@
         frame = None    # Just make sure we don't hold on to it.
         
         childProcess = getattr(os, originalName)()     # fork
-        if not childProcess and not isMultiprocessingPopen:
-            if isNewPythonProcess:
-                (wd, host, port, exceptions, tracePython, redirect,
-                 noencoding) = _debugClient.startOptions
-                _debugClient.startDebugger(
-                    filename=sys.argv[0],
-                    host=host,
-                    port=port,
-                    enableTrace=multiprocess and not isSubprocessFork,
-                    exceptions=exceptions,
-                    tracePython=tracePython,
-                    redirect=redirect,
-                    passive=False,
-                    multiprocessSupport=multiprocess)
+        if (
+            not childProcess and
+            not isMultiprocessingPopen and
+            isNewPythonProcess
+        ):
+            (wd, host, port, exceptions, tracePython, redirect,
+             noencoding) = _debugClient.startOptions
+            _debugClient.startDebugger(
+                filename=sys.argv[0],
+                host=host,
+                port=port,
+                enableTrace=multiprocess and not isSubprocessFork,
+                exceptions=exceptions,
+                tracePython=tracePython,
+                redirect=redirect,
+                passive=False,
+                multiprocessSupport=multiprocess)
         return childProcess
     
     return newFork
@@ -401,10 +405,8 @@
         patchModule(_subprocess, 'CreateProcess', createCreateProcess)
     else:
         patchModule(os, "fork", createFork)
-        try:
+        with contextlib.suppress(ImportError):
             import _posixsubprocess
             patchModule(_posixsubprocess, "fork_exec", createForkExec)
-        except ImportError:
-            pass
     
     _debugClient = debugClient

eric ide

mercurial