Philipp Hörist pushed to branch master at gajim / gajim


Commits:
ffb57db6 by Philipp Hörist at 2025-02-22T14:12:46+01:00
cfix: App: Don’t init process pool on module import

This creates on some platforms a RuntimeError see 
https://docs.python.org/3/library/multiprocessing.html#the-spawn-and-forkserver-start-methods

- - - - -


2 changed files:

- gajim/common/app.py
- gajim/common/application.py


Changes:

=====================================
gajim/common/app.py
=====================================
@@ -22,7 +22,7 @@
 
 import gc
 import logging
-import multiprocessing
+import multiprocessing.pool
 import os
 import pprint
 import signal
@@ -108,10 +108,7 @@ def __init__(self):
 
 gsound_ctx = None
 
-process_pool = multiprocessing.Pool(
-    initializer=lambda: signal.signal(signal.SIGINT, signal.SIG_IGN),
-    maxtasksperchild=10
-)
+process_pool = cast(multiprocessing.pool.Pool, None)
 
 _dependencies = {
     'FARSTREAM': False,
@@ -128,6 +125,13 @@ def __init__(self):
 _tasks: dict[int, list[Task]] = defaultdict(list)
 
 
+def init_process_pool() -> None:
+    global process_pool
+    process_pool = multiprocessing.Pool(
+        initializer=lambda: signal.signal(signal.SIGINT, signal.SIG_IGN),
+        maxtasksperchild=10
+    )
+
 def print_version() -> None:
     log('gajim').info('Gajim Version: %s', gajim.__version__)
 


=====================================
gajim/common/application.py
=====================================
@@ -63,6 +63,7 @@ def _init_core(self) -> bool:
         app.app = self
         app.print_version()
         app.detect_dependencies()
+        app.init_process_pool()
         configpaths.create_paths()
 
         app.settings = Settings()



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/ffb57db67eadf988cb0e75a38bcef6ca4a14c141

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/ffb57db67eadf988cb0e75a38bcef6ca4a14c141
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to