【发布时间】:2012-07-30 19:52:33
【问题描述】:
我觉得这不可能;但是有没有办法在 Linux 上的 Python / C 中设置匿名管道的读取超时?
有比设置和捕获 SIGALRM 更好的选择吗?
>>> import os
>>> output, input = os.pipe()
>>> outputfd = os.fdopen(output, 'r')
>>> dir(outputfd)
['__class__', '__delattr__', '__doc__', '__enter__', '__exit__', '__format__', '__getattribute__', '__hash__', '__init__', '__iter__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'close', 'closed', 'encoding', 'errors', 'fileno', 'flush', 'isatty', 'mode', 'name', 'newlines', 'next', 'read', 'readinto', 'readline', 'readlines', 'seek', 'softspace', 'tell', 'truncate', 'write', 'writelines', 'xreadlines']
>>>
(没有settimeout() 方法)
【问题讨论】: