mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-34075: Deprecate non-ThreadPoolExecutor in loop.set_default_executor() (GH-8533)
Various asyncio internals expect that the default executor is a `ThreadPoolExecutor`, so deprecate passing anything else to `loop.set_default_executor()`.
This commit is contained in:
parent
4e11c461ed
commit
22d25085db
5 changed files with 35 additions and 2 deletions
|
@ -741,6 +741,12 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||
executor.submit(func, *args), loop=self)
|
||||
|
||||
def set_default_executor(self, executor):
|
||||
if not isinstance(executor, concurrent.futures.ThreadPoolExecutor):
|
||||
warnings.warn(
|
||||
'Using the default executor that is not an instance of '
|
||||
'ThreadPoolExecutor is deprecated and will be prohibited '
|
||||
'in Python 3.9',
|
||||
DeprecationWarning, 2)
|
||||
self._default_executor = executor
|
||||
|
||||
def _getaddrinfo_debug(self, host, port, family, type, proto, flags):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue