Skip to content

Commit

Permalink
Remove cache in iscoroutinefunction to avoid holding on to refs (#5985)
Browse files Browse the repository at this point in the history
  • Loading branch information
fjetter authored Mar 24, 2022
1 parent 0e8f2f1 commit 9d3064a
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions distributed/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9d3064a

Please sign in to comment.