Files
2025-11-26 23:20:41 +08:00

27 lines
464 B
Python

#!/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())