diff -r d17bd2f00a87 -r 3bd617ae7a05 runtime/PLCObject.py --- a/runtime/PLCObject.py Fri Jan 09 17:08:31 2009 +0100 +++ b/runtime/PLCObject.py Wed Jan 14 16:41:14 2009 +0100 @@ -51,6 +51,7 @@ self._FreePLC() self.daemon = daemon self.statuschange = statuschange + self.python_threads_vars = None # Get the last transfered PLC if connector must be restart try: @@ -174,28 +175,29 @@ def PythonThreadProc(self): print "PythonThreadProc started" - my_globs = globals().copy() + 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, my_globs) + execfile(pyfile, self.python_threads_vars) res,cmd = "None","None" while self.PLCStatus == "Started": - print "_PythonIterator(", res, ")", + #print "_PythonIterator(", res, ")", cmd = self._PythonIterator(res) - print " -> ", cmd + #print " -> ", cmd if cmd is None: break try : - res = str(eval(cmd,my_globs)) + res = str(eval(cmd,self.python_threads_vars)) except Exception,e: res = "#EXCEPTION : "+str(e) print res print "PythonThreadProc interrupted" - if my_globs.get("_runtime_cleanup",None) is not None: - my_globs["_runtime_cleanup"]() + if self.python_threads_vars.get("_runtime_cleanup",None) is not None: + self.python_threads_vars["_runtime_cleanup"]() + self.python_threads_vars = None print "PythonThreadProc cleaned up" def StartPLC(self, debug=False):