Skip to content

concurrent.future.thread._python_exit: continuing blocking while exceptions occureded on windows. #127282

Closed
@GoodenoughPhysicsLab

Description

@GoodenoughPhysicsLab

Bug report

Bug description:

on windows, Thread.join is sometimes terrible because exception can not interrupt its blocking.

import threading
import time

def task():
    while True:
        time.sleep(1)

t = threading.Thread(target=task)
t.start()
t.join()

you can't exit this program by Ctrl+C on windows.

we can easily fix it to let exceptions been raisen.

import threading
import time

def task():
    while True:
        time.sleep(1)

t = threading.Thread(target=task)
t.start()
while t.is_alive():
    t.join(timeout=2)

this is what I want to fix in _python_exit, which been registered in atexit-call and it costs me a lot of time to realize what's problem with my program.

I'll send pr soon.

CPython versions tested on:

3.9, 3.10, 3.11, 3.12

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowsstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions