-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAsynclO.py
39 lines (32 loc) · 984 Bytes
/
AsynclO.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import time
import asyncio
import requests
async def function1():
URL = "https://images.pexels.com/photos/842711/pexels-photo-842711.jpeg"
response = requests.get(URL)
open("download1.jpeg","wb".write(response.content))
# time.sleep(3)
await asyncio.sleep(3)
print("func1")
async def function2():
URL = "https://images.pexels.com/photos/842711/pexels-photo-842711.jpeg"
response = requests.get(URL)
open("download2.jpeg","wb".write(response.content))
print("func2")
async def function3():
URL = "https://images.pexels.com/photos/842711/pexels-photo-842711.jpeg"
response = requests.get(URL)
open("download3.jpeg","wb".write(response.content))
print("func3")
async def main():
# L = await asyncio.gather(
# function1(),
# function2(),
# function3(),
# )
# print (L)
# task = asyncio.create_task(function1())
await function1()
await function3()
await function2()
asyncio.run(main())