Skip to content
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
15 changes: 9 additions & 6 deletions Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,12 @@ Resolve host name
This method is a :ref:`coroutine <coroutine>`, similar to
:meth:`socket.getnameinfo` function but non-blocking.

.. versionchanged:: 3.7
Both *getaddrinfo* and *getnameinfo* methods were always documented
to return a coroutine, but prior to Python 3.7 they were, in fact,
returning :class:`asyncio.Future` objects. Starting with Python 3.7
both methods are coroutines.


Connect pipes
-------------
Expand Down Expand Up @@ -852,7 +858,7 @@ Call a function in an :class:`~concurrent.futures.Executor` (pool of threads or
pool of processes). By default, an event loop uses a thread pool executor
(:class:`~concurrent.futures.ThreadPoolExecutor`).

.. coroutinemethod:: AbstractEventLoop.run_in_executor(executor, func, \*args)
.. method:: AbstractEventLoop.run_in_executor(executor, func, \*args)

Arrange for a *func* to be called in the specified executor.

Expand All @@ -862,18 +868,15 @@ pool of processes). By default, an event loop uses a thread pool executor
:ref:`Use functools.partial to pass keywords to the *func*
<asyncio-pass-keywords>`.

This method returns a :class:`asyncio.Future` object.

.. versionchanged:: 3.5.3
:meth:`BaseEventLoop.run_in_executor` no longer configures the
``max_workers`` of the thread pool executor it creates, instead
leaving it up to the thread pool executor
(:class:`~concurrent.futures.ThreadPoolExecutor`) to set the
default.

.. versionchanged:: 3.7
Even though the method was always documented as a coroutine
method, before Python 3.7 it returned a :class:`Future`.
Since Python 3.7, this is an ``async def`` method.

.. method:: AbstractEventLoop.set_default_executor(executor)

Set the default executor used by :meth:`run_in_executor`.
Expand Down
4 changes: 2 additions & 2 deletions Lib/asyncio/base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def call_soon_threadsafe(self, callback, *args, context=None):
self._write_to_self()
return handle

async def run_in_executor(self, executor, func, *args):
def run_in_executor(self, executor, func, *args):
self._check_closed()
if self._debug:
self._check_callback(func, 'run_in_executor')
Expand All @@ -730,7 +730,7 @@ async def run_in_executor(self, executor, func, *args):
if executor is None:
executor = concurrent.futures.ThreadPoolExecutor()
self._default_executor = executor
return await futures.wrap_future(
return futures.wrap_future(
executor.submit(func, *args), loop=self)

def set_default_executor(self, executor):
Expand Down
5 changes: 2 additions & 3 deletions Lib/test/test_asyncio/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2999,9 +2999,8 @@ def test_run_coroutine_threadsafe_task_factory_exception(self):
def task_factory(loop, coro):
raise NameError

run = self.loop.create_task(
self.loop.run_in_executor(
None, lambda: self.target(advance_coro=True)))
run = self.loop.run_in_executor(
None, lambda: self.target(advance_coro=True))

# Set exception handler
callback = test_utils.MockCallback()
Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.7.0a4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ Implement asyncio.create_task(coro) shortcut

Convert asyncio functions that were documented as coroutines to coroutines.
Affected functions: loop.sock_sendall, loop.sock_recv, loop.sock_accept,
loop.run_in_executor, loop.getaddrinfo, loop.getnameinfo.
loop.getaddrinfo, loop.getnameinfo.

..

Expand Down