Commits

Thomas Kluyver committed daad5c4

Initial import

Comments (0)

Files changed (1)

+from rpy2.rinterface import process_revents
+import time
+import threading
+
+START_INTERACTIVE = True
+
+class _ReventThread(threading.Thread):
+    daemon = True
+    def __init__(self, interval):
+        super(_ReventThread, self).__init__()
+        self.running = True
+        self.interval = interval
+        
+    def stop(self):
+        self.running = False
+        self.join()
+        
+    def run(self):
+        while self.running:
+            try:
+                process_revents()
+            except RuntimeError:
+                pass
+            time.sleep(self.interval)
+
+def start(interval = 0.2):
+    global eventthread
+    eventthread = _ReventThread(interval)
+    eventthread.start()
+    
+def stop():
+    eventthread.stop()
+
+if START_INTERACTIVE:
+    start()