qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [07/50] [abbrv] qpid-proton git commit: PROTON-997: Peel HandlerExceptions if they contain a python exception
Date Mon, 28 Sep 2015 18:09:33 GMT
PROTON-997: Peel HandlerExceptions if they contain a python exception


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/a82681a4
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/a82681a4
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/a82681a4

Branch: refs/heads/proton-go
Commit: a82681a454f6bda0b47b9a375d224765e002938e
Parents: 54d380e
Author: Bozo Dragojevic <bozzo@digiverse.si>
Authored: Tue Sep 15 12:06:36 2015 +0200
Committer: Bozo Dragojevic <bozzo@digiverse.si>
Committed: Wed Sep 16 15:40:05 2015 +0200

----------------------------------------------------------------------
 proton-j/src/main/resources/chandlers.py | 10 +++++++++-
 proton-j/src/main/resources/creactor.py  | 19 ++++++++++++++++---
 2 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a82681a4/proton-j/src/main/resources/chandlers.py
----------------------------------------------------------------------
diff --git a/proton-j/src/main/resources/chandlers.py b/proton-j/src/main/resources/chandlers.py
index f1761ed..272990f 100644
--- a/proton-j/src/main/resources/chandlers.py
+++ b/proton-j/src/main/resources/chandlers.py
@@ -43,5 +43,13 @@ class pn_pyhandler(BaseHandler):
         ev = pn_event(event)
         try:
             self.pyobj.dispatch(ev, pn_event_type(ev))
+        except HandlerException:
+            ex = sys.exc_info();
+            cause = ex[1].cause
+            if hasattr(cause, "value"):
+                cause = cause.value
+            t = type(cause)
+            self.pyobj.exception(t, cause, ex[2])
         except:
-            self.pyobj.exception(*sys.exc_info())
+            ex = sys.exc_info()
+            self.pyobj.exception(*ex)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a82681a4/proton-j/src/main/resources/creactor.py
----------------------------------------------------------------------
diff --git a/proton-j/src/main/resources/creactor.py b/proton-j/src/main/resources/creactor.py
index 9de7662..ffb17d3 100644
--- a/proton-j/src/main/resources/creactor.py
+++ b/proton-j/src/main/resources/creactor.py
@@ -17,11 +17,13 @@
 # under the License.
 #
 
+import sys
+from proton import _compat
 from cerror import Skipped
 from cengine import wrap, pn_connection_wrapper
 
 from org.apache.qpid.proton.reactor import Reactor
-from org.apache.qpid.proton.engine import BaseHandler
+from org.apache.qpid.proton.engine import BaseHandler, HandlerException
 
 # from proton/reactor.h
 def pn_reactor():
@@ -47,9 +49,9 @@ def pn_reactor_yield(r):
 def pn_reactor_start(r):
     r.start()
 def pn_reactor_process(r):
-    return r.process()
+    return peel_handler_exception(r.process)
 def pn_reactor_stop(r):
-    return r.stop()
+    return peel_handler_exception(r.stop)
 def pn_reactor_selectable(r):
     return r.selectable()
 def pn_reactor_connection(r, h):
@@ -61,6 +63,17 @@ def pn_reactor_mark(r):
 def pn_reactor_wakeup(r):
     return r.wakeup()
 
+def peel_handler_exception(meth):
+    try:
+        return meth()
+    except HandlerException, he:
+        cause = he.cause
+        if hasattr(cause, "value"):
+            cause = cause.value
+        t = type(cause)
+        info = sys.exc_info()
+        _compat.raise_(t, cause, info[2]) 
+
 def pn_handler_add(h, c):
     h.add(c)
 def pn_handler_dispatch(h, ev, et):


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message