Last active
February 11, 2018 06:41
-
-
Save nitely/c143752aa71bc4ca6cb42e9946422438 to your computer and use it in GitHub Desktop.
asyncio FIFO
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
import asyncio | |
async def testProc(): | |
for i in range(10): | |
await asyncio.sleep(1) | |
print("sleep") | |
def callbackProc(): | |
#print("Callback event") | |
loop = asyncio.get_event_loop() | |
loop.call_soon(callbackProc) | |
if __name__ == '__main__': | |
loop = asyncio.get_event_loop() | |
try: | |
print('task creation started') | |
asyncio.ensure_future(testProc()) | |
loop.call_soon(callbackProc) | |
loop.run_forever() | |
finally: | |
loop.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment