我想用 Python 编写一个每 30 秒触发一次 select() 的函数。
到目前为止,我的代码如下所示 -
inputs = [ UDPSock , sys.stdin]
outputs = []
while inputs:
readable, writable, exceptional = select.select(inputs, outputs, inputs)
for s in readable:
if s is UDPSock
# Deal with socket
elif s is sys.stdin:
# Deal with input
我想实现以下目标 -
inputs = [ UDPSock , sys.stdin, timer]
outputs = []
while inputs:
readable, writable, exceptional = select.select(inputs, outputs, inputs)
for s in readable:
if s is UDPSock
# Deal with socket
elif s is sys.stdin:
# Deal with input
elif s is timer:
# Deal with timer
理想情况下,如果可能的话,我希望不使用线程。