I assume by buggy you mean your conn_handler
, as written, isn’t reading from the socket until after you’ve read from stdin.
That’s because you’re specifically sequencing, with the >>=
operator, for the read from socket to happen after the read from stdin.
If you want to watch both stdin and the reader at the same time and react to either, you can try Deferred.choose
. See this recent thread Beginner async question