Python Standard Lib,signal :: AttributeError:模块'signal'没有属性'SIGALRM'

时间:2017-11-29 04:22:08

标签: python signals

我正在尝试设置函数超时但是,我无法成功。

我从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'

1 个答案:

答案 0 :(得分:0)

Windows不支持SIGALRM。 https://docs.python.org/2/library/signal.html 在Windows上,只能使用SIGABRT,SIGFPE,SIGILL,SIGINT,SIGSEGV或SIGTERM调用signal()。在任何其他情况下都会引发ValueError