Python 标准库,signal::AttributeError:模块 'signal' 没有属性 'SIGALRM'

标签 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'

最佳答案

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/

相关文章:

python - IPython 中的 __class__ 实现是否相对于 Python 进行了修改?

c# - BeautifulSoup 类似于 C#

python - 如何在集群上保存文件

python - 计算 Pandas 中数字和非数字列的每日平均值

我们可以将参数传递给 C 中的信号吗?

python - 属性错误 : 'QuerySet' object has no attribute

c - SIGINT(ctrl+c) 不中断接受调用

c - child 和 parent 之间使用信号的双向交流

c++ - 如何用C++模拟数字电路(只是输入/输出,没有图形)

pthreads - 处理segfault信号SIGSEGV需要使用siginfo_t确定segfault的原因