Skip to content

Prevent socket selector thread from being suspended #869

@davidbrochart

Description

@davidbrochart

Things to check first

  • I have searched the existing issues and didn't find my feature already requested there

Feature description

When using debugpy to debug a Python program, one might want the AnyIO socket selector thread (on Windows with the ProactorEventLoop) to keep running when the program is stopped on a breakpoint.

Use case

It's the case in ipykernel where I currently have to write something like that:

if backend == "asyncio" and sys.platform == "win32":
    import asyncio

    policy = asyncio.get_event_loop_policy()
    if policy.__class__.__name__ == "WindowsProactorEventLoopPolicy":
        from anyio._core._asyncio_selector_thread import get_selector
        selector = get_selector()
        selector._thread.pydev_do_not_trace = True

The key part is selector._thread.pydev_do_not_trace = True, that ensures the thread is not suspended.
Do you think there should be a better API for that, or should it even be done by default?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions