PROTON-1922: [Python] Con't export proton.reactor.Reactor - The correct API usage is proton.reactor.Container -- This has the same interface anyway as it is implemented as a subclass - Fixed all the places in the tests that were using Reactor
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/6aabe239 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/6aabe239 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/6aabe239 Branch: refs/heads/master Commit: 6aabe239d560419f25b4ecad6139119638a35f71 Parents: 67f137c Author: Andrew Stitcher <[email protected]> Authored: Wed Aug 29 16:05:27 2018 -0400 Committer: Andrew Stitcher <[email protected]> Committed: Wed Aug 29 16:05:27 2018 -0400 ---------------------------------------------------------------------- python/proton/reactor.py | 6 +-- python/tests/proton_tests/engine.py | 6 +-- python/tests/proton_tests/handler.py | 18 +++---- python/tests/proton_tests/reactor.py | 88 +++++++++++++++---------------- 4 files changed, 58 insertions(+), 60 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6aabe239/python/proton/reactor.py ---------------------------------------------------------------------- diff --git a/python/proton/reactor.py b/python/proton/reactor.py index 7f96f7f..639cc5b 100644 --- a/python/proton/reactor.py +++ b/python/proton/reactor.py @@ -21,8 +21,7 @@ from __future__ import absolute_import from ._reactor import Container, ApplicationEvent, EventInjector, Handler,\ LinkOption, ReceiverOption, SenderOption,\ - AtLeastOnce, AtMostOnce, DynamicNodeProperties, Filter, Selector, DurableSubscription, Copy, Move,\ - Reactor + AtLeastOnce, AtMostOnce, DynamicNodeProperties, Filter, Selector, DurableSubscription, Copy, Move __all__ = [ 'Container', @@ -39,6 +38,5 @@ __all__ = [ 'Selector', 'DurableSubscription', 'Copy', - 'Move', - 'Reactor' + 'Move' ] http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6aabe239/python/tests/proton_tests/engine.py ---------------------------------------------------------------------- diff --git a/python/tests/proton_tests/engine.py b/python/tests/proton_tests/engine.py index 3d6353e..df9e6a1 100644 --- a/python/tests/proton_tests/engine.py +++ b/python/tests/proton_tests/engine.py @@ -22,7 +22,7 @@ from __future__ import absolute_import import os, gc from time import time, sleep from proton import * -from proton.reactor import Reactor +from proton.reactor import Container from . import common from .common import pump, Skipped @@ -2046,7 +2046,7 @@ class ServerTest(Test): assert self.conn.transport.frames_input > self.old_count, "No idle frames received" self.conn.close() - Reactor(Program()).run() + Container(Program()).run() server.stop() def testIdleTimeout(self): @@ -2092,7 +2092,7 @@ class ServerTest(Test): sleep(suspend_time) p = Program() - Reactor(p).run() + Container(p).run() assert p.remote_condition assert p.remote_condition.name == "amqp:resource-limit-exceeded" server.stop() http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6aabe239/python/tests/proton_tests/handler.py ---------------------------------------------------------------------- diff --git a/python/tests/proton_tests/handler.py b/python/tests/proton_tests/handler.py index 0290d5b..89376ad 100644 --- a/python/tests/proton_tests/handler.py +++ b/python/tests/proton_tests/handler.py @@ -22,7 +22,7 @@ from __future__ import absolute_import import os, gc, traceback from proton import * -from proton.reactor import Reactor +from proton.reactor import Container from . import common @@ -45,13 +45,13 @@ class HandlerTest(common.Test): return d custom = CustomHandler() - reactor = Reactor() - reactor.handler = custom + container = Container() + container.handler = custom for i in range(n): - h = reactor.handler - reactor.handler = h + h = container.handler + container.handler = h custom.reset() - reactor.run() + container.run() assert custom.init_depth < 50, "Unexpectedly long traceback for a simple handler" def test_reactorHandlerCycling10k(self): @@ -81,10 +81,10 @@ class HandlerTest(common.Test): child = CustomInvoker() root = CustomHandler(child) - reactor = Reactor() + container = Container() - reactor_handler(reactor, root) - reactor.run() + reactor_handler(container, root) + container.run() assert root.did_init assert child.did_init assert root.did_custom http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6aabe239/python/tests/proton_tests/reactor.py ---------------------------------------------------------------------- diff --git a/python/tests/proton_tests/reactor.py b/python/tests/proton_tests/reactor.py index 08f914a..e2b4f21 100644 --- a/python/tests/proton_tests/reactor.py +++ b/python/tests/proton_tests/reactor.py @@ -21,7 +21,7 @@ from __future__ import absolute_import import time -from proton.reactor import Container, Reactor, ApplicationEvent, EventInjector +from proton.reactor import Container, ApplicationEvent, EventInjector from proton.handlers import Handshaker, MessagingHandler from proton import Handler, Url @@ -70,123 +70,123 @@ class BarfOnFinalDerived(Handshaker): class ExceptionTest(Test): def setUp(self): - self.reactor = Reactor() + self.container = Container() def test_reactor_final(self): - self.reactor.global_handler = BarfOnFinal() + self.container.global_handler = BarfOnFinal() try: - self.reactor.run() + self.container.run() assert False, "expected to barf" except Barf: pass def test_global_set(self): - self.reactor.global_handler = BarfOnInit() + self.container.global_handler = BarfOnInit() try: - self.reactor.run() + self.container.run() assert False, "expected to barf" except Barf: pass def test_global_add(self): - self.reactor.global_handler.add(BarfOnInit()) + self.container.global_handler.add(BarfOnInit()) try: - self.reactor.run() + self.container.run() assert False, "expected to barf" except Barf: pass def test_reactor_set(self): - self.reactor.handler = BarfOnInit() + self.container.handler = BarfOnInit() try: - self.reactor.run() + self.container.run() assert False, "expected to barf" except Barf: pass def test_reactor_add(self): - self.reactor.handler.add(BarfOnInit()) + self.container.handler.add(BarfOnInit()) try: - self.reactor.run() + self.container.run() assert False, "expected to barf" except Barf: pass def test_connection(self): - self.reactor.connection(BarfOnInit()) + self.container.connection(BarfOnInit()) try: - self.reactor.run() + self.container.run() assert False, "expected to barf" except Barf: pass def test_connection_set(self): - c = self.reactor.connection() + c = self.container.connection() c.handler = BarfOnInit() try: - self.reactor.run() + self.container.run() assert False, "expected to barf" except Barf: pass def test_connection_add(self): - c = self.reactor.connection() + c = self.container.connection() c.handler = object() c.handler.add(BarfOnInit()) try: - self.reactor.run() + self.container.run() assert False, "expected to barf" except Barf: pass def test_session_set(self): - c = self.reactor.connection() + c = self.container.connection() s = c.session() s.handler = BarfOnInit() try: - self.reactor.run() + self.container.run() assert False, "expected to barf" except Barf: pass def test_session_add(self): - c = self.reactor.connection() + c = self.container.connection() s = c.session() s.handler = object() s.handler.add(BarfOnInit()) try: - self.reactor.run() + self.container.run() assert False, "expected to barf" except Barf: pass def test_link_set(self): - c = self.reactor.connection() + c = self.container.connection() s = c.session() l = s.sender("xxx") l.handler = BarfOnInit() try: - self.reactor.run() + self.container.run() assert False, "expected to barf" except Barf: pass def test_link_add(self): - c = self.reactor.connection() + c = self.container.connection() s = c.session() l = s.sender("xxx") l.handler = object() l.handler.add(BarfOnInit()) try: - self.reactor.run() + self.container.run() assert False, "expected to barf" except Barf: pass def test_schedule(self): - self.reactor.schedule(0, BarfOnTask()) + self.container.schedule(0, BarfOnTask()) try: - self.reactor.run() + self.container.run() assert False, "expected to barf" except Barf: pass @@ -198,8 +198,8 @@ class ExceptionTest(Test): self.results.append(None) num = 12345 for a in range(num): - self.reactor.schedule(0, Nothing()) - self.reactor.run() + self.container.schedule(0, Nothing()) + self.container.run() assert len(Nothing.results) == num def test_schedule_many_nothing_refs(self): @@ -210,8 +210,8 @@ class ExceptionTest(Test): num = 12345 tasks = [] for a in range(num): - tasks.append(self.reactor.schedule(0, Nothing())) - self.reactor.run() + tasks.append(self.container.schedule(0, Nothing())) + self.container.run() assert len(Nothing.results) == num def test_schedule_many_nothing_refs_cancel_before_run(self): @@ -222,25 +222,25 @@ class ExceptionTest(Test): num = 12345 tasks = [] for a in range(num): - tasks.append(self.reactor.schedule(0, Nothing())) + tasks.append(self.container.schedule(0, Nothing())) for task in tasks: task.cancel() - self.reactor.run() + self.container.run() assert len(Nothing.results) == 0 def test_schedule_cancel(self): - barf = self.reactor.schedule(10, BarfOnTask()) + barf = self.container.schedule(10, BarfOnTask()) class CancelBarf: def __init__(self, barf): self.barf = barf def on_timer_task(self, event): self.barf.cancel() pass - self.reactor.schedule(0, CancelBarf(barf)) - now = self.reactor.mark() + self.container.schedule(0, CancelBarf(barf)) + now = self.container.mark() try: - self.reactor.run() - elapsed = self.reactor.mark() - now + self.container.run() + elapsed = self.container.mark() - now assert elapsed < 10, "expected cancelled task to not delay the reactor by %s" % elapsed except Barf: assert False, "expected barf to be cancelled" @@ -249,7 +249,7 @@ class ExceptionTest(Test): num = 12345 barfs = set() for a in range(num): - barf = self.reactor.schedule(10*(a+1), BarfOnTask()) + barf = self.container.schedule(10 * (a + 1), BarfOnTask()) class CancelBarf: def __init__(self, barf): self.barf = barf @@ -257,12 +257,12 @@ class ExceptionTest(Test): self.barf.cancel() barfs.discard(self.barf) pass - self.reactor.schedule(0, CancelBarf(barf)) + self.container.schedule(0, CancelBarf(barf)) barfs.add(barf) - now = self.reactor.mark() + now = self.container.mark() try: - self.reactor.run() - elapsed = self.reactor.mark() - now + self.container.run() + elapsed = self.container.mark() - now assert elapsed < num, "expected cancelled task to not delay the reactor by %s" % elapsed assert not barfs, "expected all barfs to be discarded" except Barf: --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
