From 990e648928bbd954244225885aa7680cc38deffc Mon Sep 17 00:00:00 2001 From: Brian Turek Date: Wed, 22 Apr 2020 18:00:13 +0100 Subject: [PATCH] Change run_in_executor to return a Future rather than be a coroutine (#3935) --- stdlib/3/asyncio/base_events.pyi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stdlib/3/asyncio/base_events.pyi b/stdlib/3/asyncio/base_events.pyi index 43ea39b62..db62aebe8 100644 --- a/stdlib/3/asyncio/base_events.pyi +++ b/stdlib/3/asyncio/base_events.pyi @@ -72,8 +72,10 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ...) -> Handle: ... else: def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any) -> Handle: ... - async def run_in_executor(self, executor: Any, - func: Callable[..., _T], *args: Any) -> _T: ... + # run_in_executor is defined as a coroutine in AbstractEventLoop but returns a Future in concrete implementation. + # Need to ignore mypy Return type error as a result. + def run_in_executor(self, executor: Any, # type: ignore + func: Callable[..., _T], *args: Any) -> Future[_T]: ... def set_default_executor(self, executor: Any) -> None: ... # Network I/O methods returning Futures. # TODO the "Tuple[Any, ...]" should be "Union[Tuple[str, int], Tuple[str, int, int, int]]" but that triggers