Source code for asyncutils
1# Copyright © 2026 Jonathan Dung. All rights reserved.
2# SPDX-License-Identifier: MIT
3# ruff: noqa: D104,RUF067
4from sys import implementation as I, modules as M
5match I.name:
6 case 'cpython':
7 if I.version < (3, 12): raise ImportError('asyncutils: CPython 3.12 or above required')
8 case 'graalpy':
9 if I.version[0] < 25: raise ImportError('asyncutils: GraalPy 25 (Python 3.12) or above required')
10 case s: raise ImportError(f'asyncutils is neither tested in {s} nor currently planned to be')
11from time import monotonic as T
[docs]
12def time_since_boot(t=T(), T=T): return round(T()-t, 7)*1000 # noqa: B008
13M['asyncutils._internal.log'] = __import__('logging').getLogger('asyncutils') # ty: ignore[invalid-assignment]
14def __getattr__(n, /, _=globals()):
15 from asyncutils._internal import initialize as I; _.update(__getattr__=I.Module, __all__=I.a, submodules_map=I.s, __dir__=lambda _=I.S: _)
16 try: return _[n]
17 except KeyError: return I.Module(n) # pragma: no cover
18from asyncutils.version import VersionInfo as V # noqa: E402
19time_since_boot.__text_signature__, __hexversion__, console_preloaded_submodules = '()', int(__version__ := V('1.1.0')), (preloaded_submodules := frozenset(('constants', 'context', 'cli', 'exceptions', 'version'))).union(('base', 'config', 'console')) # ty: ignore[unresolved-attribute]
20del V, I, T, M