Commits

Matthew Turk committed c3a106c

Progressbars and log entries should now get sent back from the root of the
task queue.

Comments (0)

Files changed (4)

scripts/pyro_queue.py

+from yt.config import ytcfg;ytcfg["yt","__withinreason"]="True"
 import os
 import Pyro4
 import uuid
 my_rank = comm.comm.rank
 
 if my_rank == 0:
-    from yt.config import ytcfg;ytcfg["yt","__withinreason"]="True"
     my_q = PyroQueueRoot(comm)
     Pyro4.config.HMAC_KEY = uuid.uuid4().hex
     key_file = 'reason.key'
     from yt.config import ytcfg
     if ytcfg.getboolean("yt","suppressStreamLogging"):
         return DummyProgressBar()
-    elif ytcfg.getboolean("yt", "__parallel"):
-        return ParallelProgressBar(title, maxval)
-    elif "SAGE_ROOT" in os.environ:
-        try:
-            from sage.server.support import EMBEDDED_MODE
-            if EMBEDDED_MODE: return DummyProgressBar()
-        except:
-            pass
-    elif "CODENODE" in os.environ:
-        return DummyProgressBar()
     elif ytcfg.getboolean("yt", "__withinreason"):
         from yt.gui.reason.extdirect_repl import ExtProgressBar
         return ExtProgressBar(title, maxval)
+    elif ytcfg.getboolean("yt", "__parallel"):
+        return ParallelProgressBar(title, maxval)
     widgets = [ title,
             pb.Percentage(), ' ',
             pb.Bar(marker=pb.RotatingMarker()),

yt/gui/reason/extdirect_repl.py

         threading.Thread.__init__(self)
         self.daemon = True
 
+    def heartbeat(self):
+        return
+
     def run(self):
         while 1:
             #print "Checking for a queue ..."
             except Queue.Empty:
                 if self.repl.stopped: return
                 continue
-            #print "Received the task", task
+            print "Received the task", task
             if task['type'] == 'code':
                 self.execute_one(task['code'], task['hide'])
                 self.queue.task_done()
             self.repl.payload_handler.add_payload(p)
 
     def heartbeat(self):
-        self.last_heartbeat = time.time()
-        if self.debug: print "### Heartbeat ... started: %s" % (time.ctime())
-        for i in range(30):
-            # Check for stop
-            if self.debug: print "    ###"
-            if self.stopped: return {'type':'shutdown'} # No race condition
-            if self.payload_handler.event.wait(1): # One second timeout
-                if self.debug: print "    ### Delivering payloads"
-                rv = self.payload_handler.deliver_payloads()
-                if self.debug: print "    ### Got back, returning"
-                return rv
-        if self.debug: print "### Heartbeat ... finished: %s" % (time.ctime())
-        return []
-
+        ph = self.executor.deliver()
+        for p in ph:
+            self.repl.payload_handler.add_payload(p)
 
 def reason_pylab():
     from .utils import deliver_image
                 rv = self.payload_handler.deliver_payloads()
                 if self.debug: print "    ### Got back, returning"
                 return rv
+            self.execution_thread.heartbeat()
         if self.debug: print "### Heartbeat ... finished: %s" % (time.ctime())
         return []
 
         return highlighter_css
 
     def execute(self, code, hide = False):
-            task = {'type': 'code',
-                    'code': code,
-                    'hide': hide}
-            self.execution_thread.queue.put(task)
-            return dict(status = True)
+        task = {'type': 'code',
+                'code': code,
+                'hide': hide}
+        self.execution_thread.queue.put(task)
+        return dict(status = True)
 
     def get_history(self):
         return self.executed_cell_texts[:]

yt/gui/reason/pyro_queue.py

         self.payload_handler = PayloadHandler()
         self.execution_thread.start()
 
-    def execute(self, code):
+    def execute(self, code, hide = False):
         mylog.info('Root sending out code.')
         code = self.comm.comm.bcast(code, root=0)
-        self.execution_thread.execute_one(code, False)
+        task = {'type': 'code',
+                'code': code,
+                'hide': hide}
+        self.execution_thread.queue.put(task)
 
     def deliver(self):
         return self.payload_handler.deliver_payloads()