1
我想用Python编写一个函数,每30秒触发一次select()。函数触发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
理想情况下,我想这不使用线程如果可能。
谢谢!这工作完美。 – Fletch
@Fletch,如果这有助于您随时接受我的回答(勾号按钮),以便将来帮助他人引用此问题。 – cmh