-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasyncflask.py
More file actions
32 lines (32 loc) · 1.01 KB
/
Copy pathasyncflask.py
File metadata and controls
32 lines (32 loc) · 1.01 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
#for random calling of fucntion
import asyncio
import time
import requests
start_time = time.time()
async def say_after(i):
print(f'im runnig {i}')
d = requests.get('https://test.jobiak.ai:8443/getKeyWordsBasedOnTitle?jobTitle=/'+str(i))
await asyncio.sleep(0.01)
print(f'im done {i}')
print(d.json())
return d.json()
async def desc(i):
print(f'im runnig {i}')
d = requests.get('https://test.jobiak.ai:8443/getKeyWordsBasedOnTitle?jobTitle=/' + str(i))
await asyncio.sleep(0.01)
print(f'im done {i}')
print(d.json())
return d.json()
async def main():
task=[]
# for i in range(0,5):
# task.append(say_after(i))
# print(task)
#await asyncio.gather(*task)
await asyncio.gather(say_after(200))
await asyncio.gather(desc(2))
await asyncio.gather(say_after(300))
l=asyncio.get_event_loop()
l.run_until_complete(main())
print("--- %s seconds ---" % (time.time() - start_time))
#print((t2-t1))