Calling GreenThread.wait() should return the value of the greenthread or
reraise the exception. As it is being wrapped to mimic gevent's .join
behaviour introduce the `raise_error` kwarg to allow callers to specify
the behavior they expect while maintaining backwards compatability.

Signed-off-by: Jason Kölker <[email protected]>
---
 ryu/lib/hub.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/ryu/lib/hub.py b/ryu/lib/hub.py
index 9186659..036ebb7 100644
--- a/ryu/lib/hub.py
+++ b/ryu/lib/hub.py
@@ -45,14 +45,18 @@ if HUB_TYPE == 'eventlet':
     connect = eventlet.connect
 
     def spawn(*args, **kwargs):
+        raise_error = kwargs.get('raise_error', False)
+
         def _launch(func, *args, **kwargs):
             # Mimic gevent's default raise_error=False behaviour
             # by not propagating an exception to the joiner.
             try:
-                func(*args, **kwargs)
+                return func(*args, **kwargs)
             except TaskExit:
                 pass
             except:
+                if raise_error:
+                    raise
                 # Log uncaught exception.
                 # Note: this is an intentional divergence from gevent
                 # behaviour; gevent silently ignores such exceptions.
@@ -62,14 +66,18 @@ if HUB_TYPE == 'eventlet':
         return eventlet.spawn(_launch, *args, **kwargs)
 
     def spawn_after(seconds, *args, **kwargs):
+        raise_error = kwargs.get('raise_error', False)
+
         def _launch(func, *args, **kwargs):
             # Mimic gevent's default raise_error=False behaviour
             # by not propagating an exception to the joiner.
             try:
-                func(*args, **kwargs)
+                return func(*args, **kwargs)
             except TaskExit:
                 pass
             except:
+                if raise_error:
+                    raise
                 # Log uncaught exception.
                 # Note: this is an intentional divergence from gevent
                 # behaviour; gevent silently ignores such exceptions.
-- 
2.7.3


------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to