Skip to content

Instantly share code, notes, and snippets.

@muromec
Created March 30, 2016 10:49
Show Gist options
  • Save muromec/24a4ea24a3dd5d79458e595e604aeef0 to your computer and use it in GitHub Desktop.
Save muromec/24a4ea24a3dd5d79458e595e604aeef0 to your computer and use it in GitHub Desktop.
from threading import Thread, current_thread, local
def thread():
other = current_thread()
local().name = 'WHAT?'
print 'generator hijack', next(gen)
def where_am_i():
for x in range(10):
got = yield x
print 'got this', got
th = current_thread()
print 'thread name', getattr(local(), 'name', None), th.name
def main():
main = current_thread()
local().name = 'YARRR'
next(gen)
gen.send(1)
gen = where_am_i()
main()
#something = Thread(target=thread)
#something.start()
maint = Thread(target=main)
maint.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment