--- a/connectors/PYRO/PSK_Adapter.py Wed Mar 13 10:02:11 2019 +0300
+++ b/connectors/PYRO/PSK_Adapter.py Wed Mar 13 10:19:30 2019 +0300
@@ -37,7 +37,7 @@
# receive the authentication challenge string, and use that to build the actual identification string.
try:
authChallenge = self.recvAuthChallenge(conn)
- except ProtocolError, x:
+ except ProtocolError as x:
# check if we were denied
if hasattr(x, "partialMsg") and x.partialMsg[:len(self.denyMSG)] == self.denyMSG:
raise ConnectionDeniedError(Pyro.constants.deniedReasons[int(x.partialMsg[-1])])
--- a/connectors/PYRO/__init__.py Wed Mar 13 10:02:11 2019 +0300
+++ b/connectors/PYRO/__init__.py Wed Mar 13 10:19:30 2019 +0300
@@ -73,7 +73,7 @@
# Try to get the proxy object
try:
RemotePLCObjectProxy = Pyro.core.getAttrProxyForURI(schemename + "://" + location + "/PLCObject")
- except Exception, e:
+ except Exception as e:
confnodesroot.logger.write_error(
_("Connection to {loc} failed with exception {ex}\n").format(
loc=location, exo=str(e)))
--- a/runtime/Worker.py Wed Mar 13 10:02:11 2019 +0300
+++ b/runtime/Worker.py Wed Mar 13 10:19:30 2019 +0300
@@ -51,6 +51,16 @@
self.free = Condition(self.mutex)
self.job = None
+ def reraise(self, job):
+ """
+ reraise exception happend in a job
+ @param job: job where original exception happend
+ """
+ exc_type = job.exc_info[0]
+ exc_value = job.exc_info[1]
+ exc_traceback = job.exc_info[2]
+ six.reraise(exc_type, exc_value, exc_traceback)
+
def runloop(self, *args, **kwargs):
"""
meant to be called by worker thread (blocking)
@@ -60,11 +70,8 @@
if args or kwargs:
_job = job(*args, **kwargs)
_job.do()
- if _job.success:
- # result is ignored
- pass
- else:
- raise _job.exc_info[0], _job.exc_info[1], _job.exc_info[2]
+ if not _job.success:
+ self.reraise(_job)
while not self._finish:
self.todo.wait()
@@ -106,10 +113,7 @@
if _job.success:
return _job.result
else:
- exc_type = _job.exc_info[0]
- exc_value = _job.exc_info[1]
- exc_traceback = _job.exc_info[2]
- six.reraise(exc_type, exc_value, exc_traceback)
+ self.reraise(_job)
def quit(self):
"""