feat: added examples_tutorials
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Demonstrate how to use asyncio
|
||||
"""
|
||||
|
||||
# Imports
|
||||
import asyncio
|
||||
|
||||
async def doit():
|
||||
print('Start doing...')
|
||||
await asyncio.sleep(2)
|
||||
print('Done!')
|
||||
|
||||
# Main function
|
||||
async def main() -> None:
|
||||
print('Main starts...')
|
||||
job_queue = []
|
||||
for i in range(3):
|
||||
job_queue.append(doit())
|
||||
await asyncio.gather(*job_queue)
|
||||
print('Main ends...')
|
||||
|
||||
|
||||
# Call main function
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user