我正在尝试设置函数超时,但我无法成功。
我运行来自 https://docs.python.org/3/library/signal.html?highlight=signal%20sigalrm#example 的示例代码
但是,我得到了 AttributeError
。
我在 Windows10 上使用 python 3.6.3
这是我的代码。
\>>> import signal
\>>> signal.SIGALRM
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'signal' has no attribute 'SIGALRM'
最佳答案
Windows 不支持 SIGALRM。 https://docs.python.org/2/library/signal.html 在 Windows 上,signal() 只能通过 SIGABRT、SIGFPE、SIGILL、SIGINT、SIGSEGV 或 SIGTERM 调用。在任何其他情况下都会引发 ValueError
关于Python 标准库,signal::AttributeError:模块 'signal' 没有属性 'SIGALRM',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47545002/