On 14/11/2018 13:41, exvito here wrote:
Chris, I played with this for a bit and quickly reproduced the "server side disconnect never seems to happen" behaviour you described, on my system running macOS 10.12.6 and Twisted 18.9.0 using the SelectReactor. Suspecting of an eventual race condition between "server stop listen" and "server disconnect", I tried this variation of tearDown which seems to work reliably: @defer.inlineCallbacks def tearDown(self): self.clientConnection.disconnect() yield defer.gatherResults([self.clientDisconnected, self.serverDisconnected]) yield defer.maybeDeferred(self.serverPort.stopListening) Do I have any motive to suspect such race condition? No, but after ensuring "disconnect first, stop listening later", things work much better here. Also tested the CFReactor and KQueueReactor: CFReactor seems to exhibit a similar behaviour (original code hangs every now and then on cleanup, my code works); KQueueReactor always hangs on cleanup with the original code, and works reliably with my code.
Thanks, this has worked flawlessly! cheers, Chris _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python