Skip to content

Commit 882e8c4

Browse files
committed
Try fixing thread shim on 3.14+
1 parent 521ad41 commit 882e8c4

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

hstest/common/process_utils.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,27 @@ def _adjust_thread_count(self) -> None:
2020
if self._idle_semaphore.acquire(timeout=0):
2121
return
2222

23-
# When the executor gets lost, the weakref callback will wake up
24-
# the worker threads.
2523
def weakref_cb(_, q=self._work_queue) -> None:
2624
q.put(None)
2725

2826
num_threads = len(self._threads)
2927
if num_threads < self._max_workers:
3028
thread_name = "%s_%d" % (self._thread_name_prefix or self, num_threads)
3129

32-
args = (
33-
weakref.ref(self, weakref_cb),
34-
self._work_queue,
35-
self._initializer,
36-
self._initargs,
37-
)
30+
# Python 3.14+ changed _worker signature and removed _initializer/_initargs
31+
if hasattr(self, '_create_worker_context'):
32+
args = (
33+
weakref.ref(self, weakref_cb),
34+
self._create_worker_context(),
35+
self._work_queue,
36+
)
37+
else:
38+
args = (
39+
weakref.ref(self, weakref_cb),
40+
self._work_queue,
41+
self._initializer,
42+
self._initargs,
43+
)
3844

3945
t = threading.Thread(name=thread_name, target=_worker, args=args, group=self.group)
4046
t.daemon = True

0 commit comments

Comments
 (0)