src/eric7/QScintilla/Shell.py

branch
eric7
changeset 10556
b4a75c77f9cd
parent 10554
cfcfba945421
child 10559
64db35c6e335
child 10619
bd15b5b625cb
--- a/src/eric7/QScintilla/Shell.py	Fri Feb 09 18:58:42 2024 +0100
+++ b/src/eric7/QScintilla/Shell.py	Sat Feb 10 10:58:48 2024 +0100
@@ -266,6 +266,8 @@
 
         self.clientType = ""
 
+        self.__commandExecutionTimeout = Preferences.getShell("CommandExecutionTimeout")
+
         # Initialize history
         self.__historyLists = {}
         self.__maxHistoryEntries = Preferences.getShell("MaxHistoryEntries")
@@ -1979,10 +1981,24 @@
             else:
                 self.dbs.remoteStatement(self.__getSelectedDebuggerId(), cmd)
                 now = time.monotonic()
-                while self.inCommandExecution and time.monotonic() - now < 10:
-                    # 10 seconds timeout
+                timeDelta = 0
+                while (
+                    self.inCommandExecution
+                    and timeDelta <= self.__commandExecutionTimeout
+                ):
+                    timeDelta = time.monotonic() - now
+                    # configurable timeout
                     with contextlib.suppress(KeyboardInterrupt):
                         QApplication.processEvents()
+                self.inCommandExecution = False
+                if timeDelta > self.__commandExecutionTimeout:
+                    # timeout -> write a hint into the shell window
+                    s = self.tr(
+                        "Execution of the interpreter statement timed out after"
+                        " {0} seconds.\n"
+                    ).format(self.__commandExecutionTimeout)
+                    self.__write(s)
+                    self.__clientStatement(False)
         else:
             if not self.__echoInput:
                 cmd = self.buff
@@ -2189,6 +2205,9 @@
                 self.dbs.clientProcessStderr.disconnect(self.__writeStdErr)
             self.__showStdOutErr = showStdOutErr
 
+        # do some additional configuration parameters
+        self.__commandExecutionTimeout = Preferences.getShell("CommandExecutionTimeout")
+
     @pyqtSlot(list, str)
     def __showCompletions(self, completions, text):
         """

eric ide

mercurial