AttributeError: module 'signal' has no attribute 'SIGALRM'

1,559 阅读1分钟

报错

AttributeError: module 'signal' has no attribute 'SIGALRM'

原因

signal模块可以在linux下正常使用,但在windows下却有一些限制

解答

docs.python.org/2/library/s…

"On Windows, signal() can only be called with SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, or SIGTERM. A ValueError will be raised in any other case."

也就是说在windows只有这个几个信号类型允许被使用:

SIGABRT SIGFPE SIGILL SIGINT SIGSEGV SIGTERM

其他的都会报错,具体是方法不存在:

AttributeError: module 'signal' has no attribute 'SIGTSTP'