From 47063de46ddbf5ed18ce45832c5c0bd3ec6bf4ac Mon Sep 17 00:00:00 2001 From: Sophia Ruan <104968314+XiuhuaRuan@users.noreply.github.com> Date: Thu, 4 Jan 2024 19:30:03 +0800 Subject: [PATCH] call freeze_support in main module to solve pyinstaller frozen issue (#2996) Close #2995 --- patroni/__main__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/patroni/__main__.py b/patroni/__main__.py index 229ccfb9..4d8de7e3 100644 --- a/patroni/__main__.py +++ b/patroni/__main__.py @@ -229,11 +229,6 @@ def patroni_main(configfile: str) -> None: :param configfile: path to Patroni configuration file. """ - from multiprocessing import freeze_support - - # Windows executables created by PyInstaller are frozen, thus we need to enable frozen support for - # :mod:`multiprocessing` to avoid :class:`RuntimeError` exceptions. - freeze_support() abstract_main(Patroni, configfile) @@ -335,6 +330,12 @@ def main() -> None: ``patroni`` daemon as another process. In that case relevant signals received by the main process and forwarded to ``patroni`` daemon process. """ + from multiprocessing import freeze_support + + # Executables created by PyInstaller are frozen, thus we need to enable frozen support for + # :mod:`multiprocessing` to avoid :class:`RuntimeError` exceptions. + freeze_support() + check_psycopg() args = process_arguments()