Skip to content

Commit dff665b

Browse files
cawo-odooKangOl
authored andcommitted
[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
1 parent af883ca commit dff665b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/util/snippets.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
import logging
3+
import multiprocessing
34
import re
45
from concurrent.futures import ProcessPoolExecutor
56

@@ -279,7 +280,8 @@ def convert_html_columns(cr, table, columns, converter_callback, where_column="I
279280
update_sql = ", ".join(f'"{column}" = %({column})s' for column in columns)
280281
update_query = f"UPDATE {table} SET {update_sql} WHERE id = %(id)s"
281282

282-
with ProcessPoolExecutor(max_workers=get_max_workers()) as executor:
283+
extrakwargs = {"mp_context": multiprocessing.get_context("fork")} if sys.version_info >= (3, 7) else {}
284+
with ProcessPoolExecutor(max_workers=get_max_workers(), **extrakwargs) as executor:
283285
convert = Convertor(converters, converter_callback)
284286
for query in log_progress(split_queries, logger=_logger, qualifier=f"{table} updates"):
285287
cr.execute(query)

0 commit comments

Comments
 (0)