Skip to content

Commit

Permalink
lisa: Remove dependency on nest_asyncio
Browse files Browse the repository at this point in the history
FIX

Use devlib implementation of asyncio.run() to avoid depending on
nest_asyncio as it does not work with all event loops.
  • Loading branch information
douglas-raillard-arm committed May 8, 2024
1 parent c0c4e7a commit 9ec8579
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 7 additions & 6 deletions lisa/monad.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ async def foo(x, y):
from functools import partial
from weakref import WeakKeyDictionary

import nest_asyncio
nest_asyncio.apply()

from lisa.utils import memoized, foldr, instancemethod


Expand Down Expand Up @@ -1030,9 +1027,13 @@ class AsyncIO(Async):
"""
Specialization of :class:`lisa.monad.Async` to :mod:`asyncio` event loop.
"""
# Note that this only works properly with nest_asyncio package. Otherwise,
# asyncio.run() is not re-entrant.
_run = staticmethod(asyncio.run)

@staticmethod
def _run(coro):
from devlib.utils.asyn import run
# Use devlib.utils.asyn.run() instead of asyncio.run() as it is
# re-entrant.
return run(coro)


# vim :set tabstop=4 shiftwidth=4 expandtab textwidth=80
2 changes: 0 additions & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ filterwarnings =
# warnings.warn(
# DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
ignore::DeprecationWarning:pkg_resources.*:
# Ignore this warning: https://github.com/erdewit/nest_asyncio/issues/70
ignore::DeprecationWarning:nest_asyncio.*:
ignore::PendingDeprecationWarning::
ignore::DeprecationWarning:jupyter_client.*:
ignore::DeprecationWarning:devlib.*:
Expand Down

0 comments on commit 9ec8579

Please sign in to comment.