Preserve legacy API options in worker init

This commit is contained in:
Miro 2026-05-18 18:24:04 +02:00
parent ee03327c82
commit b77b354b7f
3 changed files with 50 additions and 9 deletions

View file

@ -289,9 +289,14 @@ def test_acquire_when_multiprocessing_pool_can_initialize():
This simulates the behaviour on most common platforms.
"""
with mock.patch("multiprocessing.Pool") as pool:
result = checker._try_initialize_processpool(2, [])
options = mock.Mock()
result = checker._try_initialize_processpool(2, [], options)
pool.assert_called_once_with(2, checker._mp_init, initargs=([],))
pool.assert_called_once_with(
2,
checker._mp_init,
initargs=([], options),
)
assert result is pool.return_value
@ -308,9 +313,14 @@ def test_acquire_when_multiprocessing_pool_can_not_initialize():
https://github.com/python/cpython/blob/4e02981de0952f54bf87967f8e10d169d6946b40/Lib/multiprocessing/synchronize.py#L30-L33
"""
with mock.patch("multiprocessing.Pool", side_effect=ImportError) as pool:
result = checker._try_initialize_processpool(2, [])
options = mock.Mock()
result = checker._try_initialize_processpool(2, [], options)
pool.assert_called_once_with(2, checker._mp_init, initargs=([],))
pool.assert_called_once_with(
2,
checker._mp_init,
initargs=([], options),
)
assert result is None