File size: 705 Bytes
ab4488b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# SPDX-License-Identifier: MIT
# Copyright (c) 2019 Martijn Pieters
# Licensed under the MIT license as detailed in LICENSE.txt

# compatibility across Python versions
import asyncio
import sys

if sys.version_info < (3, 8):  # pragma: no cover
    wait_for = asyncio.wait_for
else:
    from typing import Any, Awaitable, Coroutine, Generator, TypeVar, Union

    _T = TypeVar("_T")
    _FutureLike = Union["asyncio.Future[_T]", Generator[Any, None, _T], Awaitable[_T]]

    def wait_for(
        fut: _FutureLike[_T], *args: Any, loop: Any, **kwargs: Any
    ) -> Coroutine[Any, Any, _T]:
        # loop argument is deprecated, drop it automatically
        return asyncio.wait_for(fut, *args, **kwargs)