Douglas Raillard <[email protected]> added the comment:
Drive by comment: I landed on this thread for the exact same reason:
> This situation is very frequent when e.g. a library is designed to be
> async-first, and also provides a blocking API which just wraps the async code
> by running it until complete.
The library in question is "devlib", which abstracts over SSH/adb/local shell.
We cannot make a "full" switch to async as it would be a big breaking change.
To workaround that, I came up with a decorator that wraps a corountine, and
"replaces" it such that:
@asyncf
async def f(...):
...
# Blocking call under its "normal" name, for backward compat
f()
# Used in an async environment
await f.asyn()
This allows converting bit by bit the whole library, with full backward
compatibility for both users and internal calls.
On top of that, that library is heavily used in jupyter notebooks, so all in
all, nest-asyncio is impossible to avoid.
----------
nosy: +douglas-raillard-arm
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue22239>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com