-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path72_asyncIO.py
More file actions
42 lines (35 loc) · 1.16 KB
/
72_asyncIO.py
File metadata and controls
42 lines (35 loc) · 1.16 KB
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
40
41
42
import time
import asyncio
import requests
async def function1():
print("func 1")
URL = "https://wallpaperaccess.in/public/uploads/preview/1920x1200-desktop-background-ultra-hd-wallpaper-wiki-desktop-wallpaper-4k-.jpg"
response = requests.get(URL)
open("instagram.ico", "wb").write(response.content)
return "Harry"
async def function2():
print("func 2")
URL = "https://p4.wallpaperbetter.com/wallpaper/490/433/199/nature-2560x1440-tree-snow-wallpaper-preview.jpg"
response = requests.get(URL)
open("instagram2.jpg", "wb").write(response.content)
async def function3():
print("func 3")
URL = "https://c4.wallpaperflare.com/wallpaper/622/676/943/3d-hd-wikipedia-3d-wallpaper-preview.jpg"
response = requests.get(URL)
open("instagram3.ico", "wb").write(response.content)
async def main():
# await function1()
# await function2()
# await function3()
# return 3
L = await asyncio.gather(
function1(),
function2(),
function3(),
)
print(L)
# task = asyncio.create_task(function1())
# # await function1()
# await function2()
# await function3()
asyncio.run(main())