# A TLS for the running event loop, used by _get_running_loop.
"""Default policy implementation for accessing the event loop.
thread; other threads by default have no event loop.
"""Run one full iteration of the event loop.
# Remove delayed calls that were cancelled from head of queue.
# Compute the desired timeout.
# Handle 'later' callbacks that are ready.
# This is the only place where callbacks are actually *called*.
# All other places just add them to ready.
handle = None  # Needed to break cycles when an exception occurs.
# don't have `__iter__` and `__next__` methods.
# Task is cancelled right before coro stops.
"""Coroutine that completes after a given time (in seconds)."""
return self.result() # May raise too.
"""Helper setting the result only if the future was not cancelled."""