Пример #1
0
def get_future_loop(fut: asyncio.Future) -> asyncio.AbstractEventLoop:
    try:
        # Future.get_loop() was added in Python 3.7.
        return fut.get_loop()
    except AttributeError:
        # Access private '_loop' attribute in asyncio.Future implementation as fallback.
        return fut._loop
Пример #2
0
def get_loop(future: asyncio.Future) -> asyncio.AbstractEventLoop:
    if sys.version_info >= (3, 7):
        return future.get_loop()
    else:
        return future._loop
Пример #3
0
 def _set_future_exception(future: asyncio.Future, exc: BaseException) -> None:
     future.get_loop().call_soon_threadsafe(future.set_exception, exc)
Пример #4
0
def setter(f: asyncio.Future):
    sleep(1)
    f.get_loop().call_soon_threadsafe(partial(f.set_result, None))
    print("Setting done")
Пример #5
0
 def _set_future_result(future: asyncio.Future, result: Any) -> None:
     future.get_loop().call_soon_threadsafe(future.set_result, result)