Python 用于触发select()的函数
我想用Python编写一个函数,每30秒触发一次select() 到目前为止,我的代码如下所示-Python 用于触发select()的函数,python,Python,我想用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
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
理想情况下,如果可能的话,我希望在不使用线程的情况下执行此操作。使用可选的
timeout
参数执行此操作是否有问题
e、 g
使用可选的
timeout
参数进行设置是否有问题
e、 g
@Fletch,如果这有助于您自由接受我的答案(勾选按钮),帮助其他人将来引用此问题。@Fletch,如果这有助于您自由接受我的答案(勾选按钮),帮助其他人将来引用此问题。
while True:
ready = readable, writable, exceptional = select.select(inputs, outputs,
inputs, 30.0)
if not any(ready):
#timeout condition
else:
#iterate over the ready lists as appropriate