Skip to navigation

nemo_gym.utils.deadlines

View as MarkdownOpen in Claude

Deadline helpers that do not depend on which clock the event loop uses.

Module Contents

Functions

NameDescription
monotonic_timeoutReturn an asyncio timeout that expires at a time.monotonic() deadline.

API

nemo_gym.utils.deadlines.monotonic_timeout(
deadline: float | None
) -> asyncio.Timeout

Return an asyncio timeout that expires at a time.monotonic() deadline.

asyncio.timeout_at compares its deadline with loop.time(), which is not always time.monotonic(): under uvloop on macOS, loop.time() can run days ahead of it, so a monotonic deadline passed to timeout_at expires at once. This converts the deadline to a remaining duration instead. None never expires.