- redirect stdout and stderr in child processes
This commit is contained in:
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
from collections import UserDict
|
from collections import UserDict
|
||||||
from contextlib import ExitStack
|
from contextlib import ExitStack, redirect_stderr, redirect_stdout
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from os import getpid
|
from os import getpid
|
||||||
from time import time
|
from time import time
|
||||||
@@ -531,7 +531,8 @@ class Worker:
|
|||||||
task = self.queue_in.get(True, 0.02)
|
task = self.queue_in.get(True, 0.02)
|
||||||
try:
|
try:
|
||||||
self.add_to_queue('started', task.pool_id, task.handle, pid)
|
self.add_to_queue('started', task.pool_id, task.handle, pid)
|
||||||
self.add_to_queue('done', task.pool_id, task(self.shared_memory))
|
with redirect_stdout(None), redirect_stderr(None):
|
||||||
|
self.add_to_queue('done', task.pool_id, task(self.shared_memory))
|
||||||
except Exception: # noqa
|
except Exception: # noqa
|
||||||
self.add_to_queue('task_error', task.pool_id, task.handle, format_exc())
|
self.add_to_queue('task_error', task.pool_id, task.handle, format_exc())
|
||||||
self.shared_memory.garbage_collect()
|
self.shared_memory.garbage_collect()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "parfor"
|
name = "parfor"
|
||||||
version = "2024.5.1"
|
version = "2024.7.0"
|
||||||
description = "A package to mimic the use of parfor as done in Matlab."
|
description = "A package to mimic the use of parfor as done in Matlab."
|
||||||
authors = ["Wim Pomp <wimpomp@gmail.com>"]
|
authors = ["Wim Pomp <wimpomp@gmail.com>"]
|
||||||
license = "GPLv3"
|
license = "GPLv3"
|
||||||
|
|||||||
Reference in New Issue
Block a user