Fixed deadlock in runtime's Worker. Was discovered while using WAMP and PYRO simultaneously.
authorEdouard Tisserant
Fri, 01 Feb 2019 14:14:13 +0100
changeset 2486 44c2a4e2b84d
parent 2485 ef327451d067
child 2487 6a4f9a061994
Fixed deadlock in runtime's Worker. Was discovered while using WAMP and PYRO simultaneously.
runtime/PLCObject.py
runtime/Worker.py
--- a/runtime/PLCObject.py	Thu Jan 31 14:10:06 2019 +0100
+++ b/runtime/PLCObject.py	Fri Feb 01 14:14:13 2019 +0100
@@ -37,6 +37,7 @@
 import md5
 from tempfile import mkstemp
 import shutil
+from functools import wraps
 
 from runtime.typemapping import TypeTranslator
 from runtime.loglevels import LogLevelsDefault, LogLevelsCount
@@ -72,6 +73,7 @@
 
 
 def RunInMain(func):
+    @wraps(func)
     def func_wrapper(*args, **kwargs):
         return MainWorker.call(func, *args, **kwargs)
     return func_wrapper
--- a/runtime/Worker.py	Thu Jan 31 14:10:06 2019 +0100
+++ b/runtime/Worker.py	Fri Feb 01 14:14:13 2019 +0100
@@ -65,13 +65,15 @@
                 pass
             else:
                 raise _job.exc_info[0], _job.exc_info[1], _job.exc_info[2]
+
         while not self._finish:
             self.todo.wait()
             if self.job is not None:
                 self.job.do()
                 self.done.notify()
             else:
-                self.free.notify()
+                break
+
         self.mutex.release()
 
     def call(self, *args, **kwargs):
@@ -97,8 +99,8 @@
             self.job = _job
             self.todo.notify()
             self.done.wait()
-            _job = self.job
             self.job = None
+            self.free.notify()
             self.mutex.release()
 
         if _job.success: