signal.alarm replacement in Windows [Python]

后端 未结 4 597
情深已故
情深已故 2020-12-03 20:53

I have a function that occasionally hangs.

Normally I would set an alarm, but I\'m in Windows and it\'s unavailable.

Is there a simple way around this, or sh

4条回答
  •  臣服心动
    2020-12-03 21:44

    You could - as you mentioned - just kick off a new thread that sleeps for that number of seconds.

    Or you can use one of Windows' multimedia timers (in Python, that'd be in windll.winmm). I believe timeSetEvent is what you're looking for. Incidentally, I found a piece of code that uses it here.

提交回复
热议问题