Skip to content

Instantly share code, notes, and snippets.

@earwig
Created December 23, 2016 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save earwig/c6277887f872ffd1785f9a67fc629d7c to your computer and use it in GitHub Desktop.
Save earwig/c6277887f872ffd1785f9a67fc629d7c to your computer and use it in GitHub Desktop.
>>> import inspect
>>> import threading
>>> import time
>>>
>>> def gen():
... yield 0
... time.sleep(10)
... yield 1
...
>>> a = gen()
>>>
>>> def t():
... next(a)
... next(a)
...
>>> threading.Thread(target=t).start()
>>> inspect.getgeneratorstate(a)
'GEN_RUNNING'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment