0

Possible Duplicate:
How to limit execution time of a function call in Python

I have a function that needs a 90ms timeout. How can I cause an exception or a break or whatever if that limit is reached with extreme accuracy?

Thanks

Community
  • 1
  • 1
Tampa
  • 69,424
  • 111
  • 266
  • 409
  • Old question, but wanted to note that the linked duplicate question's accepted answer can only handle integer seconds. – blthayer Aug 15 '19 at 21:18

1 Answers1

0

have a thread execute in the background that waits for approximately(can't do it accurately) 90 ms and then set an atomic boolean value to break the "wait" loop.

Aniket Inge
  • 24,753
  • 5
  • 47
  • 78
  • [threading.Event](http://docs.python.org/library/threading.html#event-objects) could be used to set the "bool". – dav1d Oct 19 '12 at 12:41