Fixed deadlock in runtime's Worker. Was discovered while using WAMP and PYRO simultaneously.
--- 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: