parent
07360bea1d
commit
e513b601ba
@ -0,0 +1,37 @@
|
||||
From 3b116169ec0f2213968780b6a2e3a85743a1a30f Mon Sep 17 00:00:00 2001
|
||||
From: Miroslav Lisik <mlisik@redhat.com>
|
||||
Date: Thu, 21 Mar 2024 13:32:10 +0100
|
||||
Subject: [PATCH] Use 'forkserver' process creation method for multiprocessing
|
||||
|
||||
* 'fork' method could cause deadlock in multiprocessing.pool.Pool on
|
||||
terminate (https://github.com/python/cpython/issues/73945)
|
||||
* https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods
|
||||
---
|
||||
pcs/daemon/run.py | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/pcs/daemon/run.py b/pcs/daemon/run.py
|
||||
index 5fa083fd..cecce750 100644
|
||||
--- a/pcs/daemon/run.py
|
||||
+++ b/pcs/daemon/run.py
|
||||
@@ -1,3 +1,4 @@
|
||||
+import multiprocessing as mp
|
||||
import os
|
||||
import signal
|
||||
import socket
|
||||
@@ -157,6 +158,12 @@ def _print_version(argv: StringCollection) -> None:
|
||||
|
||||
|
||||
def main(argv=None) -> None:
|
||||
+ # set the way how processes are started
|
||||
+ # https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods
|
||||
+ # avoid deadlock in multiprocessing.pool.Pool on terminate
|
||||
+ # https://github.com/python/cpython/issues/73945
|
||||
+ mp.set_start_method(method="forkserver")
|
||||
+
|
||||
argv = argv if argv is not None else sys.argv[1:]
|
||||
if "--version" in argv:
|
||||
_print_version(argv)
|
||||
--
|
||||
2.45.2
|
||||
|
@ -0,0 +1,43 @@
|
||||
From 661183b7352ee3e1d13398ad7571db1f811da50d Mon Sep 17 00:00:00 2001
|
||||
From: Miroslav Lisik <mlisik@redhat.com>
|
||||
Date: Fri, 22 Mar 2024 15:01:19 +0100
|
||||
Subject: [PATCH] fix logging handlers imports
|
||||
|
||||
* https://stackoverflow.com/questions/64951836/python-logging-attributeerror-module-logging-has-no-attribute-handlers/65814814#65814814
|
||||
---
|
||||
pcs/daemon/async_tasks/worker/logging.py | 3 ++-
|
||||
pcs/daemon/log.py | 1 +
|
||||
2 files changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/pcs/daemon/async_tasks/worker/logging.py b/pcs/daemon/async_tasks/worker/logging.py
|
||||
index cf5fb287..1319d651 100644
|
||||
--- a/pcs/daemon/async_tasks/worker/logging.py
|
||||
+++ b/pcs/daemon/async_tasks/worker/logging.py
|
||||
@@ -1,4 +1,5 @@
|
||||
import logging
|
||||
+import logging.handlers
|
||||
import multiprocessing as mp
|
||||
import os
|
||||
|
||||
@@ -44,7 +45,7 @@ def setup_worker_logger(queue: mp.Queue) -> logging.Logger:
|
||||
logger = logging.getLogger(WORKER_LOGGER)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
- queue_handler = logging.handlers.QueueHandler(queue) # type: ignore
|
||||
+ queue_handler = logging.handlers.QueueHandler(queue)
|
||||
logger.addHandler(queue_handler)
|
||||
|
||||
return logger
|
||||
diff --git a/pcs/daemon/log.py b/pcs/daemon/log.py
|
||||
index 07ca764a..a38cbbdf 100644
|
||||
--- a/pcs/daemon/log.py
|
||||
+++ b/pcs/daemon/log.py
|
||||
@@ -1,4 +1,5 @@
|
||||
import logging
|
||||
+import logging.handlers
|
||||
|
||||
LOGGER_NAMES = [
|
||||
"pcs.daemon",
|
||||
--
|
||||
2.45.2
|
||||
|
Loading…
Reference in new issue