fixed exception handling for events occuring during reactor shutdown (cherry picked from commit 65aa64c0e3ce88e119b0a4bf416fc2b924cf5bfb)
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/8ae8bdae Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8ae8bdae Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8ae8bdae Branch: refs/heads/0.9.x Commit: 8ae8bdae3e515ee735a2e86cf51eac4d02bc254e Parents: 9b36ff1 Author: Rafael Schloming <[email protected]> Authored: Fri Mar 27 09:45:25 2015 -0400 Committer: Robert Gemmell <[email protected]> Committed: Mon Apr 27 15:12:49 2015 +0100 ---------------------------------------------------------------------- proton-c/bindings/python/proton/reactor.py | 8 ++++++-- tests/python/proton_tests/reactor.py | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8ae8bdae/proton-c/bindings/python/proton/reactor.py ---------------------------------------------------------------------- diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py index f95bd16..dcd2507 100644 --- a/proton-c/bindings/python/proton/reactor.py +++ b/proton-c/bindings/python/proton/reactor.py @@ -131,17 +131,21 @@ class Reactor(Wrapper): def quiesced(self): return pn_reactor_quiesced(self._impl) - def process(self): - result = pn_reactor_process(self._impl) + def _check_errors(self): if self.errors: for exc, value, tb in self.errors[:-1]: traceback.print_exception(exc, value, tb) exc, value, tb = self.errors[-1] raise exc, value, tb + + def process(self): + result = pn_reactor_process(self._impl) + self._check_errors() return result def stop(self): pn_reactor_stop(self._impl) + self._check_errors() def schedule(self, delay, task): impl = _chandler(task, self.on_error) http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8ae8bdae/tests/python/proton_tests/reactor.py ---------------------------------------------------------------------- diff --git a/tests/python/proton_tests/reactor.py b/tests/python/proton_tests/reactor.py index 4bf3cdf..4e660a5 100644 --- a/tests/python/proton_tests/reactor.py +++ b/tests/python/proton_tests/reactor.py @@ -42,11 +42,24 @@ class BarfOnTask: def on_timer_task(self, event): raise Barf() +class BarfOnFinal: + + def on_reactor_final(self, event): + raise Barf() + class ExceptionTest(Test): def setup(self): self.reactor = Reactor() + def test_reactor_final(self): + self.reactor.global_handler = BarfOnFinal() + try: + self.reactor.run() + assert False, "expected to barf" + except Barf: + pass + def test_global_set(self): self.reactor.global_handler = BarfOnInit() try: --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
