mailr14750 - /1.3/gui/interpreter.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on September 26, 2011 - 13:41:
Author: bugman
Date: Mon Sep 26 13:41:26 2011
New Revision: 14750

URL: http://svn.gna.org/viewcvs/relax?rev=14750&view=rev
Log:
The GUI interpreter thread flush() method no longer hangs the thread.

The sleep calls are now outside of the interpreter thread object, avoiding 
the sleeping of the
thread.  This was causing the test suite in MS Windows to permanently hang.


Modified:
    1.3/gui/interpreter.py

Modified: 1.3/gui/interpreter.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/gui/interpreter.py?rev=14750&r1=14749&r2=14750&view=diff
==============================================================================
--- 1.3/gui/interpreter.py (original)
+++ 1.3/gui/interpreter.py Mon Sep 26 13:41:26 2011
@@ -152,8 +152,17 @@
         if status.debug:
             sys.stdout.write("debug> GUI interpreter:  Flushing.\n")
 
-        # Call the thread's method.
-        self._interpreter_thread.flush()
+        # Wait a little while to prevent races with the reading of the queue.
+        sleep(0.5)
+
+        # Loop until empty.
+        while not self._interpreter_thread.empty():
+            # Wait a bit for the queue to empty.
+            sleep(0.2)
+
+            # Wait until execution is complete.
+            while status.exec_lock.locked():
+                sleep(0.5)
 
         # Debugging.
         if status.debug:
@@ -215,10 +224,19 @@
 
 
     def empty(self):
-        """Wrapper method for the Queue.empty() method."""
-
-        # Return the queue empty state.
-        return self._queue.empty()
+        """Is the queue empty?"""
+
+        # Execution is locked.
+        if status.exec_lock.locked():
+            return False
+
+        # There are still queued calls.
+        elif len(self._uf_list):
+            return False
+
+        # The queue is empty.
+        else:
+            return True
 
 
     def exit(self):
@@ -229,22 +247,6 @@
 
         # Then queue a dummy user function.
         self._queue.put([None, None, None])
-
-
-    def flush(self):
-        """Return only once the queue is empty."""
-
-        # Wait a little while to prevent races with the reading of the queue.
-        sleep(0.5)
-
-        # Loop until empty.
-        while len(self._uf_list):
-            # Wait a bit for the queue to empty.
-            sleep(0.2)
-
-            # Wait until execution is complete.
-            while status.exec_lock.locked():
-                sleep(0.5)
 
 
     def join(self):




Related Messages


Powered by MHonArc, Updated Mon Sep 26 14:20:02 2011