From 3ef2f5cf2688217e5d83aae8f4de83630db707e5 Mon Sep 17 00:00:00 2001 From: fjetter Date: Wed, 23 Mar 2022 15:02:20 +0100 Subject: [PATCH] Remove cache in iscoroutinefunction to avoid holding on to refs --- distributed/utils.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/distributed/utils.py b/distributed/utils.py index afe048c2ac8..64203488d12 100644 --- a/distributed/utils.py +++ b/distributed/utils.py @@ -1124,21 +1124,8 @@ def color_of(x, palette=palette): return palette[n % len(palette)] -def _iscoroutinefunction(f): - return inspect.iscoroutinefunction(f) or gen.is_coroutine_function(f) - - -@functools.lru_cache(None) -def _iscoroutinefunction_cached(f): - return _iscoroutinefunction(f) - - def iscoroutinefunction(f): - # Attempt to use lru_cache version and fall back to non-cached version if needed - try: - return _iscoroutinefunction_cached(f) - except TypeError: # unhashable type - return _iscoroutinefunction(f) + return inspect.iscoroutinefunction(f) or gen.is_coroutine_function(f) @contextmanager