diff options
author | Mark Spruiell <mes@zeroc.com> | 2017-03-15 16:20:52 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2017-03-15 16:20:52 -0700 |
commit | 1c73c503727e526888d1f2fb44e9550a60ec140d (patch) | |
tree | b464fab04ed054945cff4a3950615fb0c9dc36fd /python/test | |
parent | VS 2017 UWP support (diff) | |
download | ice-1c73c503727e526888d1f2fb44e9550a60ec140d.tar.bz2 ice-1c73c503727e526888d1f2fb44e9550a60ec140d.tar.xz ice-1c73c503727e526888d1f2fb44e9550a60ec140d.zip |
ICE-7669 - Better fix for Python dispatcher
Diffstat (limited to 'python/test')
-rw-r--r-- | python/test/Ice/dispatcher/AllTests.py | 18 | ||||
-rwxr-xr-x | python/test/Ice/dispatcher/Dispatcher.py | 7 |
2 files changed, 17 insertions, 8 deletions
diff --git a/python/test/Ice/dispatcher/AllTests.py b/python/test/Ice/dispatcher/AllTests.py index b6967a9d5f9..6f03fca86b6 100644 --- a/python/test/Ice/dispatcher/AllTests.py +++ b/python/test/Ice/dispatcher/AllTests.py @@ -32,24 +32,24 @@ class Callback: def response(self, f): test(f.exception() is None) - self.checkThread() + test(Dispatcher.Dispatcher.isDispatcherThread()) self.called() def exception(self, f): test(isinstance(f.exception(), Ice.NoEndpointException)) - self.checkThread() + test(Dispatcher.Dispatcher.isDispatcherThread()) self.called() def exceptionEx(self, f): test(isinstance(f.exception(), Ice.InvocationTimeoutException)) - self.checkThread() + test(Dispatcher.Dispatcher.isDispatcherThread()) self.called() def payload(self, f): if f.exception(): test(isinstance(f.exception(), Ice.CommunicatorDestroyedException)) else: - self.checkThread() + test(Dispatcher.Dispatcher.isDispatcherThread()) def checkThread(self): # @@ -70,6 +70,8 @@ def allTests(communicator, collocated): testController = Test.TestIntfControllerPrx.uncheckedCast(obj) + dispatcher = Dispatcher.Dispatcher.instance() + sys.stdout.write("testing dispatcher... ") sys.stdout.flush() @@ -77,21 +79,21 @@ def allTests(communicator, collocated): cb = Callback() - p.opAsync().add_done_callback(cb.response) + p.opAsync().add_done_callback(cb.response, dispatcher.dispatchSync) cb.check() # # Expect NoEndpointException. # i = p.ice_adapterId("dummy") - i.opAsync().add_done_callback(cb.exception) + i.opAsync().add_done_callback(cb.exception, dispatcher.dispatchSync) cb.check() # # Expect InvocationTimeoutException. # to = p.ice_invocationTimeout(250); - to.sleepAsync(500).add_done_callback(cb.exceptionEx) + to.sleepAsync(500).add_done_callback(cb.exceptionEx, dispatcher.dispatchSync) cb.check() testController.holdAdapter() @@ -106,7 +108,7 @@ def allTests(communicator, collocated): f = None while True: f = p.opWithPayloadAsync(seq) - f.add_done_callback(cb.payload) + f.add_done_callback(cb.payload, dispatcher.dispatchSync) if not f.is_sent_synchronously(): break testController.resumeAdapter() diff --git a/python/test/Ice/dispatcher/Dispatcher.py b/python/test/Ice/dispatcher/Dispatcher.py index 809f7500920..1c48b947a84 100755 --- a/python/test/Ice/dispatcher/Dispatcher.py +++ b/python/test/Ice/dispatcher/Dispatcher.py @@ -29,6 +29,9 @@ class Dispatcher: if len(self._calls) == 1: self._cond.notify() + def dispatchSync(self, call): + self.dispatch(call, None) + def run(self): while True: call = None @@ -60,3 +63,7 @@ class Dispatcher: @staticmethod def isDispatcherThread(): return threading.current_thread() == Dispatcher._instance._thread + + @staticmethod + def instance(): + return Dispatcher._instance |