# test.py
import os
from multiprocessing import Process, current_process
def worker(num):
ret = num * 2
name = current_process().name
print(f'{num} * 2 = {ret} by {name} process')
if __name__ == "__main__" :
process_name = ['A', 'B', 'C', 'D']
procs = []
for index, number in enumerate(process_name):
proc = Process(target=worker, args=(number, ))
procs.append(proc)
proc.start()
proc = Process(target=worker, name='Test', args=(2, ))
proc.start()
procs.append(proc)
for proc in procs:
proc.join()
[파이썬(Python)] #6. list comprehension (0) | 2021.08.22 |
---|---|
[파이썬(Python)] #22. for문 / enumerate 내장함수사용 (0) | 2021.08.20 |
[파이썬(Python)] #20. thread (0) | 2021.08.20 |
[파이썬(Python)] #16. 문자열/숫자 - 배열 입력받기 (0) | 2021.08.19 |
[파이썬(Python)] #15. List에 map 사용하기 (0) | 2021.08.19 |