1

I'm curious whether is there some kind of time-out for methods so I can for example repeat the method after 50 seconds of acting like being idle.

This SO answer achieves this using signal.alarm, but I'm on Windows so this isn't available.

The only thing that comes to mind is to use time.now() and another thread, but it doesn't feel very effective.

Is there a better way?

Community
  • 1
  • 1
Milano
  • 18,048
  • 37
  • 153
  • 353
  • Is [this](http://stackoverflow.com/a/601168/2071807) of any use? – LondonRob Jul 28 '15 at 08:13
  • @LondonRob I'm not sure because it is not working on Windows which I work on. – Milano Jul 28 '15 at 08:19
  • You could make the thread you want to wait on unconditionally acquire a lock when it starts execution and release it when it's finished. Then, in another or the main thread try to conditionally acquire the same lock repeatedly, doing other work or a `time.sleep()` between attempts. When that finally succeeds you know the other thread finished its execution. – martineau Jul 28 '15 at 08:22
  • possible duplicate of [signal.alarm replacement in Windows \[Python\]](http://stackoverflow.com/questions/644073/signal-alarm-replacement-in-windows-python) – LondonRob Jul 28 '15 at 08:27

0 Answers0