我正在尝试设置函数超时,但是没有成功。
我从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'
Run Code Online (Sandbox Code Playgroud)
小智 9
Windows 不支持 SIGALRM。 https://docs.python.org/2/library/signal.html 在 Windows 上,signal() 只能使用 SIGABRT、SIGFPE、SIGILL、SIGINT、SIGSEGV 或 SIGTERM 调用。在任何其他情况下都会引发 ValueError