Having a console in a single-threaded Python script

前端 未结 2 957
攒了一身酷
攒了一身酷 2020-12-15 14:44

I would like to have an interactive console in a single-threaded script that has several TCP connections open. This means I can\'t just have a standard input blocking the th

2条回答
  •  温柔的废话
    2020-12-15 15:34

    Either single-threaded or multi-threaded will do, but if you choose not to use threads, you will need to use polling (in C this may be done using poll(2), for example) and check for whether the console and/or the TCP connections have input ready.

提交回复
热议问题