diff options
Diffstat (limited to 'python/test/Ice/acm/TestI.py')
-rw-r--r-- | python/test/Ice/acm/TestI.py | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/python/test/Ice/acm/TestI.py b/python/test/Ice/acm/TestI.py index 10565ca9540..41f5afe93eb 100644 --- a/python/test/Ice/acm/TestI.py +++ b/python/test/Ice/acm/TestI.py @@ -9,6 +9,21 @@ import Ice, Test, threading +class ConnectionCallbackI(): + def __init__(self): + self.m = threading.Condition() + self.count = 0 + + def heartbeat(self, con): + with self.m: + self.count += 1 + self.m.notifyAll() + + def waitForCount(self, count): + with self.m: + while self.count < count: + self.m.wait() + class RemoteCommunicatorI(Test._RemoteCommunicatorDisp): def createObjectAdapter(self, timeout, close, heartbeat, current=None): com = current.adapter.getCommunicator() @@ -68,26 +83,9 @@ class TestIntfI(Test._TestIntfDisp): with self.m: self.m.notifyAll() - def waitForHeartbeat(self, count, current=None): - - class ConnectionCallbackI(): - - def __init__(self): - self.m = threading.Condition() - self.count = 0 - - def heartbeat(self, con): - with self.m: - self.count -= 1 - self.m.notifyAll() - - def waitForCount(self, count): - with self.m: - self.count = count - while self.count > 0: - self.m.wait() - - callback = ConnectionCallbackI() - current.con.setHeartbeatCallback(lambda con: callback.heartbeat(con)) - callback.waitForCount(2) + def startHeartbeatCount(self, current=None): + self.callback = ConnectionCallbackI() + current.con.setHeartbeatCallback(lambda con: self.callback.heartbeat(con)) + def waitForHeartbeatCount(self, count, current=None): + self.callback.waitForCount(2) |