diff options
author | Mark Spruiell <mes@zeroc.com> | 2016-12-09 15:18:08 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2016-12-09 15:18:08 -0800 |
commit | 3b7e9f99b61538e0bbd6f07deeb7f7cb12013ed5 (patch) | |
tree | a8edbf5d1043527cc50880b34ee83458ed7e4855 /python/test/Ice/faultTolerance/AllTests.py | |
parent | Merge remote-tracking branch 'origin/3.6' (diff) | |
download | ice-3b7e9f99b61538e0bbd6f07deeb7f7cb12013ed5.tar.bz2 ice-3b7e9f99b61538e0bbd6f07deeb7f7cb12013ed5.tar.xz ice-3b7e9f99b61538e0bbd6f07deeb7f7cb12013ed5.zip |
ICE-7138 - new Python AMI mapping based on futures and modified AMD mapping
Diffstat (limited to 'python/test/Ice/faultTolerance/AllTests.py')
-rw-r--r-- | python/test/Ice/faultTolerance/AllTests.py | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/python/test/Ice/faultTolerance/AllTests.py b/python/test/Ice/faultTolerance/AllTests.py index 94263cf1602..c55c3a138da 100644 --- a/python/test/Ice/faultTolerance/AllTests.py +++ b/python/test/Ice/faultTolerance/AllTests.py @@ -22,37 +22,32 @@ class CallbackBase: self._cond = threading.Condition() def check(self): - self._cond.acquire() - try: + with self._cond: while not self._called: self._cond.wait() self._called = False - finally: - self._cond.release() def called(self): - self._cond.acquire() - self._called = True - self._cond.notify() - self._cond.release() + with self._cond: + self._called = True + self._cond.notify() class Callback(CallbackBase): - def response(self): - test(False) - - def exception(self, ex): - test(False) - - def opPidI(self, pid): - self._pid = pid - self.called() + def opPidI(self, f): + try: + self._pid = f.result() + self.called() + except: + test(False) - def opShutdownI(self): + def opShutdownI(self, f): + test(f.exception() is None) self.called() - def exceptAbortI(self, ex): + def exceptAbortI(self, f): + test(f.exception() is not None) try: - raise ex + f.result() except Ice.ConnectionLostException: pass except Ice.ConnectFailedException: @@ -102,7 +97,7 @@ def allTests(communicator, ports): sys.stdout.write("testing server #%d with AMI... " % i) sys.stdout.flush() cb = Callback() - obj.begin_pid(cb.opPidI, cb.exception) + obj.pidAsync().add_done_callback(cb.opPidI) cb.check() pid = cb.pid() test(pid != oldPid) @@ -119,7 +114,7 @@ def allTests(communicator, ports): sys.stdout.write("shutting down server #%d with AMI... " % i) sys.stdout.flush() cb = Callback() - obj.begin_shutdown(cb.opShutdownI, cb.exception) + obj.shutdownAsync().add_done_callback(cb.opShutdownI) cb.check() print("ok") elif j == 1 or i + 1 > len(ports): @@ -137,7 +132,7 @@ def allTests(communicator, ports): sys.stdout.write("aborting server #%d with AMI... " % i) sys.stdout.flush() cb = Callback() - obj.begin_abort(cb.response, cb.exceptAbortI) + obj.abortAsync().add_done_callback(cb.exceptAbortI) cb.check() print("ok") elif j == 2 or j == 3: @@ -155,7 +150,7 @@ def allTests(communicator, ports): sys.stdout.write("aborting server #%d and #%d with idempotent AMI call... " % (i, i + 1)) sys.stdout.flush() cb = Callback() - obj.begin_idempotentAbort(cb.response, cb.exceptAbortI) + obj.idempotentAbortAsync().add_done_callback(cb.exceptAbortI) cb.check() print("ok") |