Adding Lock around C code called by Debug thread
authorgreg
Sat, 30 May 2009 16:44:07 +0200
changeset 353 c68fc75ebb06
parent 352 81777d4e379c
child 354 ff721067a75c
Adding Lock around C code called by Debug thread
runtime/PLCObject.py
--- a/runtime/PLCObject.py	Thu May 28 17:29:19 2009 +0200
+++ b/runtime/PLCObject.py	Sat May 30 16:44:07 2009 +0200
@@ -25,7 +25,6 @@
 import Pyro.core as pyro
 from threading import Timer, Thread, Lock
 import ctypes, os, commands, types, sys
-import time
 
 if os.name in ("nt", "ce"):
     from _ctypes import LoadLibrary as dlopen
@@ -405,7 +404,9 @@
         Return a list of variables, corresponding to the list of required idx
         """
         if self.PLCStatus == "Started":
+            self.PLClibraryLock.acquire()
             tick = self._WaitDebugData()
+            #PLCprint("Debug tick : %d"%tick)
             if tick == -1:
                 res = None
             else:
@@ -422,10 +423,8 @@
                     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()
+            self.PLClibraryLock.release()
             return tick, res
         return -1, None
-        
-
-
+