eric6/DebugClients/Python/ThreadExtension.py

branch
maintenance
changeset 8273
698ae46f40a4
parent 8043
0acf98cd089a
parent 8240
93b8a353c4bf
--- a/eric6/DebugClients/Python/ThreadExtension.py	Fri Apr 02 11:59:41 2021 +0200
+++ b/eric6/DebugClients/Python/ThreadExtension.py	Sat May 01 14:27:20 2021 +0200
@@ -9,6 +9,7 @@
 
 import os
 import sys
+import contextlib
 
 import _thread
 import threading
@@ -18,7 +19,7 @@
 _qtThreadNumber = 1
 
 
-class ThreadExtension(object):
+class ThreadExtension:
     """
     Class implementing the thread support for the debugger.
     
@@ -95,9 +96,8 @@
         """
         self.lockClient()
         try:
-            del self.threads[threadId]
-        except KeyError:
-            pass
+            with contextlib.suppress(KeyError):
+                del self.threads[threadId]
         finally:
             self.unlockClient()
     
@@ -116,10 +116,8 @@
         """
         Public method to release the lock for this client.
         """
-        try:
+        with contextlib.suppress(RuntimeError):
             self.clientLock.release()
-        except RuntimeError:
-            pass
     
     def setCurrentThread(self, threadId):
         """
@@ -298,7 +296,7 @@
                 # intercept the thread creation by threading.Thread
                 self.run = lambda s=self, run=self.run: _bootstrap(s, run)
                 
-                super(ThreadWrapper, self).__init__(*args, **kwargs)
+                super().__init__(*args, **kwargs)
         
         module.Thread = ThreadWrapper
         
@@ -313,7 +311,7 @@
                 """
                 Constructor
                 """
-                super(TimerWrapper, self).__init__(
+                super().__init__(
                     interval, function, *args, **kwargs)
         
         module.Timer = TimerWrapper
@@ -327,7 +325,7 @@
                 """
                 Constructor
                 """
-                super(DummyThreadWrapper, self).__init__(*args, **kwargs)
+                super().__init__(*args, **kwargs)
         
         module._DummyThread = DummyThreadWrapper
     
@@ -390,7 +388,7 @@
                 self.run = lambda s=self, run=self.run: (
                     _bootstrapQThread(s, run))
                 
-                super(QThreadWrapper, self).__init__(*args, **kwargs)
+                super().__init__(*args, **kwargs)
         
         class QRunnableWrapper(module.QRunnable):
             """
@@ -405,7 +403,7 @@
                 self.run = lambda s=self, run=self.run: (
                     _bootstrapQThread(s, run))
                 
-                super(QRunnableWrapper, self).__init__(*args, **kwargs)
+                super().__init__(*args, **kwargs)
         
         module.QThread = QThreadWrapper
         module.QRunnable = QRunnableWrapper

eric ide

mercurial