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