Skip to content

Commit a44eca3

Browse files
committed
Fix the interrupt thread is deadlocking when receiving an interrupt
1 parent e5d1a43 commit a44eca3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/tox/session/cmd/run/common.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ def execute(state: State, max_workers: Optional[int], has_spinner: bool, live: b
211211
if cancelled is False and not future.done(): # pragma: no branch
212212
tox_env.interrupt()
213213
done.wait()
214+
# workaround for https://bugs.python.org/issue45274
215+
lock = getattr(thread, "_tstate_lock", None)
216+
if lock is not None and lock.locked():
217+
lock.release()
218+
thread._stop() # type: ignore # we must call this private method to fix the thread state
219+
thread.join()
214220
finally:
215221
ordered_results: List[ToxEnvRunResult] = []
216222
name_to_run = {r.name: r for r in results}

0 commit comments

Comments
 (0)