사용자 도구

사이트 도구


multiprocessing

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판이전 판
다음 판
이전 판
multiprocessing [2021/02/16 15:07] rex8312multiprocessing [2024/03/23 02:38] (현재) – 바깥 편집 127.0.0.1
줄 1: 줄 1:
 ====== multiprocessing ====== ====== multiprocessing ======
- 
-  * Uber Fiber 
-    * https://uber.github.io/fiber/ 
-    * multiprocessing과 사용법이 동일한 분산 컴퓨팅 
- 
-  * loky: resuable pool executer 
-    * https://pypi.org/project/loky/ 
- 
-  * Array 공유 
-    * https://pypi.org/project/SharedArray/ 
- 
  
   * 자식프로세스 출력 redirection   * 자식프로세스 출력 redirection
줄 32: 줄 21:
 # https://stackoverflow.com/questions/7714868/python-multiprocessing-how-can-i-reliably-redirect-stdout-from-a-child-process # https://stackoverflow.com/questions/7714868/python-multiprocessing-how-can-i-reliably-redirect-stdout-from-a-child-process
 </code> </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.1613488029.txt.gz · 마지막으로 수정됨: (바깥 편집)