Make AbstractEventLoop.run_in_executor return an Awaitable, instead of being a coroutine (#4457)

Closes: #3999
This commit is contained in:
James Weaver
2020-08-18 11:17:31 +01:00
committed by GitHub
parent 61537be530
commit 512c154638
2 changed files with 2 additions and 6 deletions

View File

@@ -68,11 +68,7 @@ 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: ...
# 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( # type: ignore
self, executor: Any, func: Callable[..., _T], *args: Any,
) -> Future[_T]: ...
def run_in_executor(self, executor: Any, func: Callable[..., _T], *args: Any,) -> Future[_T]: ...
def set_default_executor(self, executor: Any) -> None: ...
# Network I/O methods returning Futures.
async def getaddrinfo(

View File

@@ -116,7 +116,7 @@ class AbstractEventLoop(metaclass=ABCMeta):
@abstractmethod
def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any) -> Handle: ...
@abstractmethod
async def run_in_executor(self, executor: Any, func: Callable[..., _T], *args: Any) -> _T: ...
def run_in_executor(self, executor: Any, func: Callable[..., _T], *args: Any) -> Awaitable[_T]: ...
@abstractmethod
def set_default_executor(self, executor: Any) -> None: ...
# Network I/O methods returning Futures.