From f3aaa15b9b1f85376318d81bad1b5b7283712202 Mon Sep 17 00:00:00 2001 From: "Carsten Wolff (cawo)" Date: Wed, 9 Jul 2025 13:33:30 +0000 Subject: [PATCH] [IMP] snippets: prepare for changed default in python 3.14 Cited from documentation: > Note The default multiprocessing start method (see Contexts and start > methods) will change away from fork in Python 3.14. Code that requires fork > be used for their ProcessPoolExecutor should explicitly specify that by > passing a `mp_context=multiprocessing.get_context("fork")` parameter.[^1] [^1]: https://docs.python.org/3/library/concurrent.futures.html#processpoolexecutor --- src/util/snippets.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/snippets.py b/src/util/snippets.py index a4e091546..fd9b25b7e 100644 --- a/src/util/snippets.py +++ b/src/util/snippets.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import inspect import logging +import multiprocessing import re import sys import uuid @@ -305,7 +306,8 @@ def convert_html_columns(cr, table, columns, converter_callback, where_column="I update_sql = ", ".join(f'"{column}" = %({column})s' for column in columns) update_query = f"UPDATE {table} SET {update_sql} WHERE id = %(id)s" - with ProcessPoolExecutor(max_workers=get_max_workers()) as executor: + extrakwargs = {"mp_context": multiprocessing.get_context("fork")} if sys.version_info >= (3, 7) else {} + with ProcessPoolExecutor(max_workers=get_max_workers(), **extrakwargs) as executor: convert = Convertor(converters, converter_callback) for query in log_progress(split_queries, logger=_logger, qualifier=f"{table} updates"): cr.execute(query)