1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-09-02 01:51:53 +01:00

utils/asyn: Replace nest_asyncio with greenlet

Provide an implementation of re-entrant asyncio.run() that is less
brittle than what greenback provides (e.g. no use of ctypes to poke
extension types).

The general idea of the implementation consists in treating the executed
coroutine as a generator, then turning that generator into a generator
implemented using greenlet. This allows a nested function to make the
top-level parent yield values on its behalf, as if every call was
annotated with "yield from".
This commit is contained in:
Douglas Raillard
2024-05-09 16:26:00 +01:00
committed by Marc Bonnici
parent b2e19d333b
commit fb4e155696
3 changed files with 554 additions and 14 deletions

View File

@@ -17,6 +17,7 @@
import sys
import asyncio
from functools import partial
import contextvars
from concurrent.futures import ThreadPoolExecutor
from contextlib import contextmanager