mirror of
https://github.com/python/cpython.git
synced 2025-08-15 06:10:47 +00:00
bpo-36373: Deprecate explicit loop parameter in all public asyncio APIs [locks] (GH-13920)
This PR deprecate explicit loop parameters in all public asyncio APIs
This issues is split to be easier to review.
Third step: locks.py
https://bugs.python.org/issue36373
(cherry picked from commit 537877d85d
)
Co-authored-by: Emmanuel Arias <emmanuelarias30@gmail.com>
This commit is contained in:
parent
ab74e52f76
commit
bb8fc8bd30
7 changed files with 419 additions and 265 deletions
|
@ -43,12 +43,13 @@ class BaseTest(test_utils.TestCase):
|
|||
class LockTests(BaseTest):
|
||||
|
||||
def test_context_manager_async_with(self):
|
||||
primitives = [
|
||||
asyncio.Lock(loop=self.loop),
|
||||
asyncio.Condition(loop=self.loop),
|
||||
asyncio.Semaphore(loop=self.loop),
|
||||
asyncio.BoundedSemaphore(loop=self.loop),
|
||||
]
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
primitives = [
|
||||
asyncio.Lock(loop=self.loop),
|
||||
asyncio.Condition(loop=self.loop),
|
||||
asyncio.Semaphore(loop=self.loop),
|
||||
asyncio.BoundedSemaphore(loop=self.loop),
|
||||
]
|
||||
|
||||
async def test(lock):
|
||||
await asyncio.sleep(0.01)
|
||||
|
@ -65,12 +66,13 @@ class LockTests(BaseTest):
|
|||
self.assertFalse(primitive.locked())
|
||||
|
||||
def test_context_manager_with_await(self):
|
||||
primitives = [
|
||||
asyncio.Lock(loop=self.loop),
|
||||
asyncio.Condition(loop=self.loop),
|
||||
asyncio.Semaphore(loop=self.loop),
|
||||
asyncio.BoundedSemaphore(loop=self.loop),
|
||||
]
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
primitives = [
|
||||
asyncio.Lock(loop=self.loop),
|
||||
asyncio.Condition(loop=self.loop),
|
||||
asyncio.Semaphore(loop=self.loop),
|
||||
asyncio.BoundedSemaphore(loop=self.loop),
|
||||
]
|
||||
|
||||
async def test(lock):
|
||||
await asyncio.sleep(0.01)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue