From 5ff2b08b4ab834508cb2dad5b401b0a463784227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Mon, 7 Apr 2025 14:58:59 +0200 Subject: [PATCH] Move multithreading patch up so that it's working in the GUI --- dangerzone/__init__.py | 6 ++++++ dangerzone/gui/__init__.py | 1 + dangerzone/gui/main_window.py | 4 ---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dangerzone/__init__.py b/dangerzone/__init__.py index f029398..a67ebcf 100644 --- a/dangerzone/__init__.py +++ b/dangerzone/__init__.py @@ -4,6 +4,12 @@ import sys logger = logging.getLogger(__name__) +# Call freeze_support() to avoid passing unknown options to the subprocess. +# See https://github.com/freedomofpress/dangerzone/issues/873 +import multiprocessing + +multiprocessing.freeze_support() + try: from . import vendor # type: ignore [attr-defined] diff --git a/dangerzone/gui/__init__.py b/dangerzone/gui/__init__.py index 5a4c26c..cee8a0e 100644 --- a/dangerzone/gui/__init__.py +++ b/dangerzone/gui/__init__.py @@ -10,6 +10,7 @@ from typing import List, Optional import click import colorama + # FIXME: See https://github.com/freedomofpress/dangerzone/issues/320 for more details. if typing.TYPE_CHECKING: from PySide2 import QtCore, QtGui, QtWidgets diff --git a/dangerzone/gui/main_window.py b/dangerzone/gui/main_window.py index 52ac9a1..f10d500 100644 --- a/dangerzone/gui/main_window.py +++ b/dangerzone/gui/main_window.py @@ -3,7 +3,6 @@ import os import platform import tempfile import typing -from multiprocessing import freeze_support from multiprocessing.pool import ThreadPool from pathlib import Path from typing import List, Optional @@ -1238,9 +1237,6 @@ class DocumentsListWidget(QtWidgets.QListWidget): def start_conversion(self) -> None: if not self.thread_pool_initized: max_jobs = self.dangerzone.isolation_provider.get_max_parallel_conversions() - # Call freeze_support() to avoid passing unknown options to the subprocess. - # See https://github.com/freedomofpress/dangerzone/issues/873 - freeze_support() self.thread_pool = ThreadPool(max_jobs) for doc in self.docs_list: