python - Stop a tornado.TCPServer without waiting for connections to close -


the docs tornado.tcpserver.tcpserver.stop say:

requests in progress may still continue after server stopped

however, test robustness want simulate full crash of server.

is there preferred way abruptly terminate tornado.tcpserver? in particular want terminate open sockets ungracefully.

edit

so don't think stop terminates existing connections. following code prints 1, 2

from tornado import gen tornado.ioloop import ioloop tornado.tcpserver import tcpserver tornado.tcpclient import tcpclient  port = 9000  class server(tcpserver):     @gen.coroutine     def handle_stream(self, stream, address):         while true:             bytes = yield stream.read_bytes(5)             yield stream.write(bytes)  server = server() server.listen(port)  @gen.coroutine def client():     client = tcpclient()     stream = yield client.connect('127.0.0.1', port)     yield stream.write(b'hello')     result = yield stream.read_bytes(5)     assert result == b'hello'     print(1)      server.stop()      yield stream.write(b'hello')     result = yield stream.read_bytes(5)     assert result == b'hello'     print(2)  ioloop.current().run_sync(client) 

tcpserver.stop want; comment quoted warning tcpserver makes no attempt @ graceful shutdown.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -