# HG changeset patch
# User greg
# Date 1243694647 -7200
# Node ID c68fc75ebb06f3deac943732ebefac8ac62149cb
# Parent  81777d4e379cf500a7ad7ff99599366b8a1ca689
Adding Lock around C code called by Debug thread

diff -r 81777d4e379c -r c68fc75ebb06 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
-        
-
-
+