5

Python signal doesn't seem to work on Windows even if I run the python script inside Cygwin. I'm getting the AttributeError: 'module' object has no attribute SIGALRM

Is there a way to go around this on Windows. I'm just running the example at the end of http://docs.python.org/2/library/signal.html

ToniAz
  • 430
  • 1
  • 6
  • 24
  • 1
    Is Python installed through Cygwin? – Blender May 04 '13 at 06:45
  • 2
    A signal is a Posix thing and most likely won't work on Windows. Cygwin is just translation layer and may not translate signal semantics to whatever Windows uses (but I'm not sure, I'd have to test it). – Keith May 04 '13 at 06:47
  • Indeed, installing Python through Cygwin (setup-x86_64.exe in my case) fixed the problem for me. – Josiah Yoder Nov 17 '16 at 00:12

1 Answers1

6

SIGALRM doesn't work in Windows. From the documentation:

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

This question addresses the topic of getting a SIGALRM equivalent in Windows. And this question is also similar.

Community
  • 1
  • 1
tiago
  • 22,602
  • 12
  • 72
  • 88
  • Why did [this code](http://stackoverflow.com/questions/366682/how-to-limit-execution-time-of-a-function-call-in-python/601168#601168) work on Python 2 on Windows (if I remember right) and break on Python 3 on Windows? Maybe I was using a Python installed through cygwin... – Josiah Yoder Nov 16 '16 at 23:09
  • Indeed, installing the Python that comes with Cygwin worked for me. – Josiah Yoder Nov 17 '16 at 00:04