Created
March 30, 2016 10:49
-
-
Save muromec/24a4ea24a3dd5d79458e595e604aeef0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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