multiprocessing
차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판이전 판다음 판 | 이전 판 | ||
multiprocessing [2021/02/16 15:07] – rex8312 | multiprocessing [2024/03/23 02:38] (현재) – 바깥 편집 127.0.0.1 | ||
---|---|---|---|
줄 21: | 줄 21: | ||
# https:// | # https:// | ||
</ | </ | ||
+ | |||
+ | <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(" | ||
+ | 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 | ||
+ | </ | ||
+ | |||
===== multiprocessing 대체 모듈 ===== | ===== multiprocessing 대체 모듈 ===== |
multiprocessing.1613488063.txt.gz · 마지막으로 수정됨: (바깥 편집)