def test_reconnect(self):
"""
If the connection is lost, the L{RemoteObject} created by the factory
will transparently handle the reconnection.
"""
self.client.factor = 0.01 # Try reconnecting very quickly
connector = reactor.connectUNIX(self.socket, self.client)
remote = yield self.client.getRemoteObject()
# Disconnect and wait till we connect again
deferred = Deferred()
self.client.notifyOnConnect(deferred.callback)
connector.disconnect()
yield deferred
# The remote object is still working
result = yield remote.method("john")
self.assertEqual(result, "John")
self.client.stopTrying()
connector.disconnect()
评论列表
文章目录