Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache is_coroutine_function #4481

Merged
merged 1 commit into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions distributed/actor.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import asyncio
import functools
from inspect import iscoroutinefunction
import threading
from queue import Queue

from .client import Future, default_client
from .protocol import to_serialize
from .utils import thread_state, sync
from .utils import iscoroutinefunction, thread_state, sync
from .utils_comm import WrappedKey
from .worker import get_worker

Expand Down
4 changes: 2 additions & 2 deletions distributed/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,7 @@ def color_of(x, palette=palette):
return palette[n % len(palette)]


@functools.lru_cache(None)
def iscoroutinefunction(f):
return inspect.iscoroutinefunction(f) or gen.is_coroutine_function(f)

Expand Down Expand Up @@ -1343,8 +1344,7 @@ def parse_ports(port):
return ports


def is_coroutine_function(f):
return asyncio.iscoroutinefunction(f) or gen.is_coroutine_function(f)
is_coroutine_function = iscoroutinefunction


class Log(str):
Expand Down