docs: add class docstring to _LoopWrapper (#27870)

Document the purpose of the daemon thread that backs the sync
branch of the timeout decorator.

Co-authored-by: oss-agent-shin <279349115+oss-agent-shin@users.noreply.github.com>
This commit is contained in:
oss-agent-shin 2026-05-13 13:54:00 -07:00 committed by GitHub
parent ca82761e48
commit 714664fe21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -90,6 +90,13 @@ def timeout(timeout_duration: float = 0.0, exception_to_raise=Timeout):
class _LoopWrapper(Thread):
"""Daemon thread that owns a dedicated asyncio event loop.
Used by the sync branch of :func:`timeout` to run a coroutine on a
background event loop so the calling thread can wait on it with a
timeout via :func:`asyncio.run_coroutine_threadsafe`.
"""
def __init__(self):
super().__init__(daemon=True)
self.loop = asyncio.new_event_loop()