-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile_client.py
More file actions
53 lines (39 loc) · 1.17 KB
/
file_client.py
File metadata and controls
53 lines (39 loc) · 1.17 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
43
44
45
46
47
48
49
50
51
52
import requests
import time
from PIL import Image
import multiprocessing
import os
def worker_client(i):
print ('Worker',i)
url = 'http://127.0.0.1:5000/im_size' #Localhost
#url = 'http://192.168.38.8:5000/im_size' #ML2
imgnam = os.path.join('client_images', str(i)+'.jpg')
my_img = {'image': open(imgnam, 'rb')}
payload = {'id': '123', 'type': 'jpg'}
start = time.time()
r = requests.post(url, files=my_img, data=payload)
print('time for round trip of {}:'.format(i),time.time()-start)
# convert server response into JSON format.
#print(r.json())
def worker(i):
"""worker function"""
print ('Worker',i)
time.sleep(1)
return
if __name__ == '__main__':
start2=time.time()
jobs = []
parcalls=5
for i in range(parcalls):
p = multiprocessing.Process(target=worker_client, args=(i,))
jobs.append(p)
p.start()
for j in jobs:
j.join()
print('******* Time per call:',(time.time()-start2)/parcalls)
'''
start = time.time()
img = Image.open("/home/skycam/basics/opencv_basics/encode_decode/0.jpg")
print(img.width, img.height)
print('Time:',time.time()-start)
'''