MCPcopy Create free account
hub / github.com/ActiveState/code / test

Function test

recipes/Python/577959_Run_async_code_inline/recipe-577959.py:23–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21
22@async
23def test():
24 # We start in the main thread
25 print "1 %s" % threading.currentThread()
26 yield
27
28 # This part is run in a seperate thread, not blocking the main thread
29 print "2 %s" % threading.currentThread()
30 yield
31
32 # Now we are back in the main thread
33 print "3 %s" % threading.currentThread()
34 yield
35
36 # And in another background thread
37 print "4 %s" % threading.currentThread()
38 yield
39
40 # And we keep all internal variables between the threads!
41 print "5 %s" % threading.currentThread()
42
43if __name__ == "__main__":
44 test()

Callers 1

recipe-577959.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected