- htttp://archsaber.com
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 asyncio | |
# definition of a coroutine | |
async def coroutine_1(): | |
print('coroutine_1 is active on the event loop') | |
print('coroutine_1 yielding control. Going to be blocked for 4 seconds') | |
await asyncio.sleep(4) | |
print('coroutine_1 resumed. coroutine_1 exiting') |
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 asyncio | |
# this is a coroutine definition | |
async def fake_network_request(request): | |
print('making network call for request: ' + request) | |
# simulate network delay | |
await asyncio.sleep(1) | |
return 'got network response for request: ' + request |