30 lines
531 B
Python
30 lines
531 B
Python
#!/usr/bin/python3
|
|
"""
|
|
Documentation
|
|
Demonstrate how to use asyncio
|
|
|
|
License: This program is released under the MIT License
|
|
"""
|
|
|
|
# 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())
|