mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-05-29 08:07:05 +08:00
Fix forward reference warning in documentation (#25150)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
parent
c9ff9e6f0c
commit
5a33ae9a3f
@ -16,19 +16,6 @@ if sys.version_info[:2] >= (3, 11):
|
|||||||
from asyncio import timeout as asyncio_timeout
|
from asyncio import timeout as asyncio_timeout
|
||||||
else:
|
else:
|
||||||
|
|
||||||
def asyncio_timeout(delay: Optional[float]) -> "Timeout":
|
|
||||||
"""timeout context manager.
|
|
||||||
Useful in cases when you want to apply timeout logic around block
|
|
||||||
of code or in cases when asyncio.wait_for is not suitable. For example:
|
|
||||||
>>> async with timeout(0.001):
|
|
||||||
... async with aiohttp.get('https://github.com') as r:
|
|
||||||
... await r.text()
|
|
||||||
delay - value in seconds or None to disable timeout logic
|
|
||||||
"""
|
|
||||||
loop = asyncio.get_running_loop()
|
|
||||||
deadline = loop.time() + delay if delay is not None else None
|
|
||||||
return Timeout(deadline, loop)
|
|
||||||
|
|
||||||
class _State(enum.Enum):
|
class _State(enum.Enum):
|
||||||
INIT = "INIT"
|
INIT = "INIT"
|
||||||
ENTER = "ENTER"
|
ENTER = "ENTER"
|
||||||
@ -171,3 +158,16 @@ else:
|
|||||||
self._state = _State.TIMEOUT
|
self._state = _State.TIMEOUT
|
||||||
# drop the reference early
|
# drop the reference early
|
||||||
self._timeout_handler = None
|
self._timeout_handler = None
|
||||||
|
|
||||||
|
def asyncio_timeout(delay: Optional[float]) -> Timeout:
|
||||||
|
"""timeout context manager.
|
||||||
|
Useful in cases when you want to apply timeout logic around block
|
||||||
|
of code or in cases when asyncio.wait_for is not suitable. For example:
|
||||||
|
>>> async with timeout(0.001):
|
||||||
|
... async with aiohttp.get('https://github.com') as r:
|
||||||
|
... await r.text()
|
||||||
|
delay - value in seconds or None to disable timeout logic
|
||||||
|
"""
|
||||||
|
loop = asyncio.get_running_loop()
|
||||||
|
deadline = loop.time() + delay if delay is not None else None
|
||||||
|
return Timeout(deadline, loop)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user