From 241fc7f02bd9e0d18263427c8e5f847a38ca05f2 Mon Sep 17 00:00:00 2001
From: Danilo Piparo <danilo.piparo@cern.ch>
Date: Tue, 15 Jan 2019 20:19:28 +0100
Subject: [PATCH] [JupyROOT] Improve code logic and adapt test

---
 bindings/pyroot/JupyROOT/helpers/handlers.py | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/bindings/pyroot/JupyROOT/helpers/handlers.py b/bindings/pyroot/JupyROOT/helpers/handlers.py
index dd4904dfa2c..635aa2ce532 100644
--- a/bindings/pyroot/JupyROOT/helpers/handlers.py
+++ b/bindings/pyroot/JupyROOT/helpers/handlers.py
@@ -88,6 +88,7 @@ class Poller(Thread):
                 self.ro_ref().is_running = False
             else:
                 self.poll = False
+                self.ro_ref().is_running = False
         return
 
 class Runner(object):
@@ -107,7 +108,7 @@ class Runner(object):
     >>> r.AsyncRun("Asynchronous");print("Synchronous");time.sleep(1)
     Synchronous
     Asynchronous
-    >>> r.AsyncRun("Asynchronous"); print(r.HasFinished())
+    >>> r.AsyncRun("Asynchronous"); time.sleep(.2); print(r.HasFinished())
     False
     >>> time.sleep(1)
     Asynchronous
@@ -131,20 +132,16 @@ class Runner(object):
         return self.function(argument)
 
     def AsyncRun(self, argument):
-        self.is_running = True
         self.argument_queue.put(argument)
 
     def Wait(self):
         while self.is_running: pass
 
     def HasFinished(self):
-        if self.is_running: return False
-        return True
+        return False if self.is_running else True
 
     def Stop(self):
-        self.Wait()
         self.argument_queue.put(None)
-        self.Wait()
 
 
 class JupyROOTDeclarer(Runner):
-- 
GitLab