mirror of
https://github.com/python/cpython.git
synced 2025-11-03 15:11:34 +00:00
bpo-42392: Improve removal of *loop* parameter in asyncio primitives (GH-23499)
* Update code after merge review from 1st1 * Use a sentinel approach for loop parameter Remove unnecessary _get_running_loop patching * Use more clear function name (_verify_parameter_is_marker -> _verify_no_loop) * Add init method to _LoopBoundMixin to check that loop param wasn't used
This commit is contained in:
parent
7301979b23
commit
b9127dd6ee
5 changed files with 46 additions and 35 deletions
|
|
@ -541,31 +541,10 @@ def new_test_loop(self, gen=None):
|
|||
self.set_event_loop(loop)
|
||||
return loop
|
||||
|
||||
def unpatch_get_running_loop(self):
|
||||
events._get_running_loop = self._get_running_loop
|
||||
|
||||
def setUp(self):
|
||||
self._get_running_loop = events._get_running_loop
|
||||
|
||||
def _get_running_loop():
|
||||
frame = sys._getframe(1)
|
||||
|
||||
if frame.f_globals['__name__'] == 'asyncio.mixins':
|
||||
# When we called from LoopBoundedMixin we should
|
||||
# fallback to default implementation of get_running_loop
|
||||
try:
|
||||
return events.get_running_loop()
|
||||
except RuntimeError:
|
||||
return None
|
||||
|
||||
return None
|
||||
|
||||
events._get_running_loop = _get_running_loop
|
||||
self._thread_cleanup = threading_helper.threading_setup()
|
||||
|
||||
def tearDown(self):
|
||||
self.unpatch_get_running_loop()
|
||||
|
||||
events.set_event_loop(None)
|
||||
|
||||
# Detect CPython bug #23353: ensure that yield/yield-from is not used
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue