Skip to content

Instantly share code, notes, and snippets.

@dmitryhd
Created April 21, 2016 11:10
Show Gist options
  • Select an option

  • Save dmitryhd/2b16e1f2afaf6b79a40f984fcc0feca4 to your computer and use it in GitHub Desktop.

Select an option

Save dmitryhd/2b16e1f2afaf6b79a40f984fcc0feca4 to your computer and use it in GitHub Desktop.
import stopit
with stopit.ThreadingTimeout(3) as to_ctx_mgr:
assert to_ctx_mgr.state == to_ctx_mgr.EXECUTING
# Something potentially very long but which
sleep(2)
print('done')
print(bool(to_ctx_mgr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment