forked from TeamCookCaps/ImageClassification
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkProcess.py
More file actions
52 lines (40 loc) · 1.37 KB
/
WorkProcess.py
File metadata and controls
52 lines (40 loc) · 1.37 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 multiprocessing
from Upload import Upload
from Remove import Remove
class WorkProcess():
# 이미지 업로드
def upload(self, image, result):
item = {}
item['image_name'] = image
remote_path = Upload(image).upload_cloudinary()
if remote_path == 'error image upload':
return remote_path
item['remote'] = remote_path['url']
print(item)
result.append(item)
# 멀티프로세스 이미지 업로드 함수
def multi_upload(self, image_list):
manager = multiprocessing.Manager()
result = manager.list()
jobs = []
# 멀티 프로세싱을 사용해 병렬처리
for i in range(len(image_list)):
process = multiprocessing.Process(
target=self.upload, args=(image_list[i], result))
jobs.append(process)
process.start()
# 프로세스 종료 대기
for proc in jobs:
proc.join()
return result
# 이미지 삭제
def remove(self, image_list):
# item = {}
# item['image_name'] = image_list
result = Remove(image_list).remove_cloudinary()
return result
# if remote_path == 'error image remove':
# return remote_path
# item['remote'] = remote_path['url']
# print(item)
# result.append(item)