def tearDown(self):
if self.agent:
# clean up connections for twisted.web.client.Agent test.
self.agent.closeCachedConnections()
self.agent = None
# If the test indicated it might leave some server-side connections
# around, clean them up.
connections = list(self.wrapper.protocols.keys())
# If there are fewer server-side connections than requested,
# that's okay. Some might have noticed that the client closed
# the connection and cleaned up after themselves.
for n in range(min(len(connections), self.cleanupServerConnections)):
proto = connections.pop()
msg("Closing %r" % (proto,))
proto.transport.abortConnection()
d = self.port.stopListening()
return defer.DeferredList([waitUntilAllDisconnected(
reactor, list(self.wrapper.protocols.keys())), d])
评论列表
文章目录