Skip to content

Commit 6bb98de

Browse files
committed
[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 closes #294 Related: odoo/upgrade#8239 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent af883ca commit 6bb98de

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/util/snippets.py

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

68
from lxml import etree, html
@@ -279,7 +281,8 @@ def convert_html_columns(cr, table, columns, converter_callback, where_column="I
279281
update_sql = ", ".join(f'"{column}" = %({column})s' for column in columns)
280282
update_query = f"UPDATE {table} SET {update_sql} WHERE id = %(id)s"
281283

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

0 commit comments

Comments
 (0)