Skip to content

from_thread.run(_sync)? does not set sniffio on asyncio #523

@gschaffner

Description

@gschaffner

note that from_thread.run(_sync)? does set sniffio on trio, however.

this causes a few bugs:

  1. from_thread.run(_sync)? fails when used to call sniffio-dependent functions when the to_thread worker is running a non-asyncio async backend known to sniffio (i.e. trio, curio, or (situationally) trio-asyncio) and the thread that started the worker is on asyncio.

    reproducer: bc3cc49.

  2. because BlockingPortal._spawn_task_from_thread shares its underlying implementation with from_thread.run_sync on asyncio, using a BlockingPortal that was started by start_blocking_portal("asyncio") in a non-asyncio async backend known to sniffio deadlocks.

    reproducer: cd9deb1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions