Change run_in_executor to return a Future rather than be a coroutine (#3935)

This commit is contained in:
Brian Turek
2020-04-22 18:00:13 +01:00
committed by GitHub
parent 51e5b98076
commit 990e648928

View File

@@ -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