diff --git a/changelogs/fragments/fix-for-workerprocess-stdout-deadlock-fix.yml b/changelogs/fragments/fix-for-workerprocess-stdout-deadlock-fix.yml new file mode 100644 index 00000000000..9d8d11dcebb --- /dev/null +++ b/changelogs/fragments/fix-for-workerprocess-stdout-deadlock-fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - "WorkerProcess - Python 3.5 fix for workaround for stdout deadlock in multiprocessing shutdown to avoid process hangs. (https://github.com/ansible/ansible/issues/74149)" diff --git a/lib/ansible/executor/process/worker.py b/lib/ansible/executor/process/worker.py index 983df45bca2..510928c0edc 100644 --- a/lib/ansible/executor/process/worker.py +++ b/lib/ansible/executor/process/worker.py @@ -145,8 +145,7 @@ class WorkerProcess(multiprocessing_context.Process): # TODO: Evaluate overhauling ``Display`` to not write directly to stdout # and evaluate migrating away from the ``fork`` multiprocessing start method. if sys.version_info[0] >= 3: - sys.stdout = os.devnull - sys.stderr = os.devnull + sys.stdout = sys.stderr = open(os.devnull, 'w') def _run(self): '''