Skip to content

Instantly share code, notes, and snippets.

@nitely
Last active February 11, 2018 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nitely/c143752aa71bc4ca6cb42e9946422438 to your computer and use it in GitHub Desktop.
Save nitely/c143752aa71bc4ca6cb42e9946422438 to your computer and use it in GitHub Desktop.
asyncio FIFO
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