Why is signal.SIGALRM not working in Python on windows?

前端 未结 1 1000
無奈伤痛
無奈伤痛 2021-01-11 13:24

I\'m trying to understand OS concepts and Python libraries.

I came across a specific example mentioned in Python documentation https://docs.python.org/3/library/sign

相关标签:
1条回答
  • 2021-01-11 14:21

    Is there any specific reason why singal.SIGALRM is not working on windows?

    Yes, Windows OS doesn't implement that signal. The example you found starts with:

    Here is a minimal example program. It uses the alarm() function to limit the time spent waiting to open a file; [...]

    and the signal.alarm() function is documented as:

    Availability: Unix.

    Next, the SIG* section elsewhere on the module documentation page states:

    Note that not all systems define the same set of signal names; only those names defined by the system are defined by this module.

    So SIGALRM is not available on Windows so you get an attribute error instead.

    Note that Windows also does not have a /dev virtual filesystem, so the os.open('/dev/ttyS0', os.O_RDWR) call would fail too.

    See python: windows equivalent of SIGALRM for an alternative using threads.

    0 讨论(0)
提交回复
热议问题