--- a/runtime/PLCObject.py Fri Jan 16 16:52:23 2009 +0100
+++ b/runtime/PLCObject.py Fri Jan 16 16:59:18 2009 +0100
@@ -178,22 +178,32 @@
- def ExecRuntimePy(self):
+ def PrepareRuntimePy(self): self.python_threads_vars = globals().copy()
pyfile = os.path.join(self.workingdir, "runtime.py")
if os.path.exists(pyfile):
- # TODO handle exceptions in runtime.py
- # pyfile may redefine _runtime_cleanup
- # or even call _PythonThreadProc itself.
- execfile(pyfile, self.python_threads_vars)
+ # TODO handle exceptions in runtime.py + # pyfile may redefine _runtime_cleanup + # or even call _PythonThreadProc itself. + execfile(pyfile, self.python_threads_vars) + PLCprint(traceback.format_exc()) + def BeginRuntimePy(self): + runtime_begin = self.python_threads_vars.get("_runtime_begin",None) + if runtime_begin is not None: def FinishRuntimePy(self):
- if self.python_threads_vars.get("_runtime_cleanup",None) is not None:
- self.python_threads_vars["_runtime_cleanup"]()
+ runtime_cleanup = self.python_threads_vars.get("_runtime_cleanup",None) + if runtime_cleanup is not None: self.python_threads_vars = None
def PythonThreadProc(self):
PLCprint("PythonThreadProc started")
while self.PLCStatus == "Started":
#print "_PythonIterator(", res, ")",
@@ -217,7 +227,7 @@
self.PLCStatus = "Started"
+ self.PrepareRuntimePy() self.PythonThread = Thread(target=self.PythonThreadProc)
self.PythonThread.start()