summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorElvis Pranskevichus <elvis@magic.io>2018-07-30 10:42:43 (GMT)
committerVictor Stinner <vstinner@redhat.com>2018-07-30 10:42:43 (GMT)
commit22d25085db2590932b3664ca32ab82c08f2eb2db (patch)
treed173242dc2c035baf83bf36eb26d992618c1e796 /Lib/asyncio
parent4e11c461ed39085b8495a35c9367b46d8a0d306d (diff)
downloadcpython-22d25085db2590932b3664ca32ab82c08f2eb2db.zip
cpython-22d25085db2590932b3664ca32ab82c08f2eb2db.tar.gz
cpython-22d25085db2590932b3664ca32ab82c08f2eb2db.tar.bz2
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()`.
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/base_events.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index dc0ca3f..75989a7 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -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):