Python错误:AttributeError: module 'signal' has no attribute 'SIGALRM'

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/polyhedronx/article/details/81988335

电脑系统是win10 64位,在使用python的signal模块时报错:“AttributeError: module 'signal' has no attribute 'SIGALRM'”,这是因为signal模块可以在linux下正常使用,但在windows下却有一些限制,在python文档https://docs.python.org/2/library/signal.html#signal.signal找到了如下解释:

"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

参考:

Missing signal.SIGHUP on windows breaks logging to file

Python Signal 信号

浅析Python中signal包的使用

猜你喜欢

转载自blog.csdn.net/polyhedronx/article/details/81988335