Created
July 1, 2016 00:57
-
-
Save nakamuray/bc46db9f5045a74ce847590afb5fa3eb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import threading | |
from asyncio_extras.threads import threadpool | |
async def main(): | |
print('main:', threading.current_thread()) | |
for _ in range(4): | |
async with threadpool(): | |
import time | |
print('within threadpool:', threading.current_thread()) | |
time.sleep(1) | |
print('within threadpool:', threading.current_thread(), 'done') | |
print('main:', threading.current_thread(), 'done') | |
if __name__ == '__main__': | |
import asyncio | |
loop = asyncio.get_event_loop() | |
#loop.run_until_complete(main()) | |
loop.run_until_complete(asyncio.wait([main(), main()])) |
Author
nakamuray
commented
Jul 1, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment