Skip to content

Commit

Permalink
Try fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wjsi committed May 24, 2022
1 parent ed38d1b commit a46e9f0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions mars/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

from mars.config import option_context
from mars.core.mode import is_kernel_mode, is_build_mode
from mars.lib.aio.lru import clear_all_alru_caches
from mars.oscar.backends.router import Router
from mars.oscar.backends.ray.communication import RayServer
from mars.serialization.ray import register_ray_serializers, unregister_ray_serializers
Expand All @@ -30,6 +31,11 @@
MARS_CI_BACKEND = os.environ.get("MARS_CI_BACKEND", "mars")


@pytest.fixture(autouse=True)
def auto_cleanup(request):
request.addfinalizer(clear_all_alru_caches)


@pytest.fixture(scope="module")
def ray_start_regular_shared(request): # pragma: no cover
yield from _ray_start_regular(request)
Expand Down
14 changes: 13 additions & 1 deletion mars/lib/aio/lru.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,23 @@
# THE SOFTWARE.

import asyncio
import os
import weakref
from collections import OrderedDict
from functools import _CacheInfo, _make_key, partial, wraps


__version__ = "1.0.2"

__all__ = ("alru_cache",)
__all__ = ("alru_cache", "clear_all_alru_caches")

_is_ci = (os.environ.get("CI") or "0").lower() in ("1", "true")
_all_wrapped = weakref.WeakSet()


def clear_all_alru_caches():
for wrapped in _all_wrapped:
wrapped.cache_clear()


def unpartial(fn):
Expand Down Expand Up @@ -206,6 +216,8 @@ async def wrapped(*fn_args, **fn_kwargs):
wrapped.close = partial(_close, wrapped)
wrapped.open = partial(_open, wrapped)

if _is_ci:
_all_wrapped.add(wrapped)
return wrapped

if fn is None:
Expand Down

0 comments on commit a46e9f0

Please sign in to comment.