내용으로 건너뛰기
Out of the Box
사용자 도구
로그인
사이트 도구
검색
도구
문서 보기
이전 판
Fold/unfold all
역링크
최근 바뀜
미디어 관리자
사이트맵
로그인
>
최근 바뀜
미디어 관리자
사이트맵
추적:
•
go-exploration
•
prompt_toolkit
multiprocessing
이 문서는 읽기 전용입니다. 원본을 볼 수는 있지만 바꿀 수는 없습니다. 문제가 있다고 생각하면 관리자에게 문의하세요.
====== multiprocessing ====== * 자식프로세스 출력 redirection <code python> import app import io import sys from multiprocessing import Process def run_app(some_param): sys.stdout = io.TextIOWrapper(open(sys.stdout.fileno(), 'wb', 0), write_through=True) app.run() app_process = Process(target=run_app, args=('some_param',)) app_process.start() # Use app_process.termninate() for python <= 3.7. app_process.kill() # https://stackoverflow.com/questions/7714868/python-multiprocessing-how-can-i-reliably-redirect-stdout-from-a-child-process </code> <code python> original_stdout = sys.stdout buffer = deque(maxlen=128) class IOLoggerWrapper(io.StringIO): def write(self, string): buffer.append(string) return len(string) root = logging.getLogger() handler = logging.StreamHandler(IOLoggerWrapper()) formatter = logging.Formatter("[%(asctime)s][%(name)s][%(levelname)s][%(message)s]") handler.setFormatter(formatter) root.addHander(handler) class IOWrapper(io.StringIO): def write(self, string): original_stdout.write(string) buffer.append(string) return len(string) io_wrapper = IOWrapper() sys.stdout = io_wrapper sys.stderr = io_wrapper </code> ===== multiprocessing 대체 모듈 ===== * Uber Fiber * https://uber.github.io/fiber/ * multiprocessing과 사용법이 동일한 분산 컴퓨팅 * loky: resuable pool executer * https://pypi.org/project/loky/ * Array 공유 * https://pypi.org/project/SharedArray/
multiprocessing.txt
· 마지막으로 수정됨: 2024/03/23 02:38 저자
127.0.0.1
문서 도구
문서 보기
이전 판
역링크
Fold/unfold all
맨 위로