mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +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
|
@ -1,5 +1,6 @@
|
|||
"""Tests for base_events.py"""
|
||||
|
||||
import concurrent.futures
|
||||
import errno
|
||||
import logging
|
||||
import math
|
||||
|
@ -211,10 +212,21 @@ class BaseEventLoopTests(test_utils.TestCase):
|
|||
self.assertFalse(self.loop._ready)
|
||||
|
||||
def test_set_default_executor(self):
|
||||
executor = mock.Mock()
|
||||
class DummyExecutor(concurrent.futures.ThreadPoolExecutor):
|
||||
def submit(self, fn, *args, **kwargs):
|
||||
raise NotImplementedError(
|
||||
'cannot submit into a dummy executor')
|
||||
|
||||
executor = DummyExecutor()
|
||||
self.loop.set_default_executor(executor)
|
||||
self.assertIs(executor, self.loop._default_executor)
|
||||
|
||||
def test_set_default_executor_deprecation_warnings(self):
|
||||
executor = mock.Mock()
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.loop.set_default_executor(executor)
|
||||
|
||||
def test_call_soon(self):
|
||||
def cb():
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue