Ian Kelly <ian.g.ke...@gmail.com>: > On Sat, Nov 25, 2017 at 7:10 AM, John Pote <johnp...@jptechnical.co.uk> wrote: >> The issue is that if I press a key on the keyboard the key is >> immediately shown on the screen but then the shutdown() call blocks >> until another TCP connection is made, text is echoed back and only >> then does serve_forever()return followed by shutdown()returning as >> can be seen from the console session, > [...] > Make a connection to the server after calling shutdown to wake up the > server's event loop? I'm guessing it only checks the shutdown flag > after responding to an event, so there's probably not much else you > could do.
Seems to be one of the fundamental multithreading issues: each thread is blocked on precisely one event. Asyncio is more flexible: you can multiplex on a number of events. Marko -- https://mail.python.org/mailman/listinfo/python-list