# HG changeset patch # User greg # Date 1242625644 -7200 # Node ID 25b7b7f854bc4bac9aa898fe8b17ce53af54a3d0 # Parent fe2d1936b5468c1fc916e602e0c67d23bc39f86a Wait the debug thread has terminated before freeing PLC to avoid random segmentation fault. Store working directory to globals copy, in order to be used in runtime.py. diff -r fe2d1936b546 -r 25b7b7f854bc runtime/PLCObject.py --- a/runtime/PLCObject.py Mon May 18 07:43:03 2009 +0200 +++ b/runtime/PLCObject.py Mon May 18 07:47:24 2009 +0200 @@ -25,6 +25,7 @@ import Pyro.core as pyro from threading import Timer, Thread import ctypes, os, commands, types, sys +import time if os.name in ("nt", "ce"): from _ctypes import LoadLibrary as dlopen @@ -32,7 +33,7 @@ elif os.name == "posix": from _ctypes import dlopen, dlclose -import os,sys,traceback +import traceback lib_ext ={ "linux2":".so", @@ -180,6 +181,7 @@ def PrepareRuntimePy(self): self.python_threads_vars = globals().copy() + self.python_threads_vars["WorkingDir"] = self.workingdir pyfile = os.path.join(self.workingdir, "runtime.py") hmifile = os.path.join(self.workingdir, "hmi.py") if os.path.exists(hmifile): @@ -276,6 +278,8 @@ self.PLCStatus = "Stopped" self.StatusChange() self._stopPLC() + if self.PythonThread.isAlive(): + self.PythonThread.join() if self._FreePLC(): self.PLCStatus = "Dirty" self.StatusChange() @@ -414,6 +418,7 @@ else: PLCprint("Debug error idx : %d, expected_idx %d, type : %s"%(idx.value, given_idx,typename.value)) res.append(None) + time.sleep(0.1) self._FreeDebugData() return tick, res return -1, None diff -r fe2d1936b546 -r 25b7b7f854bc runtime/__init__.py --- a/runtime/__init__.py Mon May 18 07:43:03 2009 +0200 +++ b/runtime/__init__.py Mon May 18 07:47:24 2009 +0200 @@ -2,5 +2,5 @@ import os -from PLCObject import PLCObject +from PLCObject import PLCObject, PLCprint import ServicePublisher