summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorEmmanuel Arias <emmanuelarias30@gmail.com>2019-09-10 10:55:07 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-09-10 10:55:07 (GMT)
commit537877d85d1c27d2c2f5189e39da64a7a0c413d3 (patch)
tree44b52523924c0c5496ceba24ffbe0b6ba95e569f /Lib/asyncio
parent9669931e5e76cf4b6ae6d3d66e699b5fd6ffe931 (diff)
downloadcpython-537877d85d1c27d2c2f5189e39da64a7a0c413d3.zip
cpython-537877d85d1c27d2c2f5189e39da64a7a0c413d3.tar.gz
cpython-537877d85d1c27d2c2f5189e39da64a7a0c413d3.tar.bz2
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
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/locks.py41
1 files changed, 29 insertions, 12 deletions
diff --git a/Lib/asyncio/locks.py b/Lib/asyncio/locks.py
index 1324eef..f63d4ce 100644
--- a/Lib/asyncio/locks.py
+++ b/Lib/asyncio/locks.py
@@ -160,10 +160,13 @@ class Lock(_ContextManagerMixin):
def __init__(self, *, loop=None):
self._waiters = None
self._locked = False
- if loop is not None:
- self._loop = loop
- else:
+ if loop is None:
self._loop = events.get_event_loop()
+ else:
+ self._loop = loop
+ warnings.warn("The loop argument is deprecated since Python 3.8, "
+ "and scheduled for removal in Python 3.10.",
+ DeprecationWarning, stacklevel=2)
def __repr__(self):
res = super().__repr__()
@@ -253,10 +256,13 @@ class Event:
def __init__(self, *, loop=None):
self._waiters = collections.deque()
self._value = False
- if loop is not None:
- self._loop = loop
- else:
+ if loop is None:
self._loop = events.get_event_loop()
+ else:
+ self._loop = loop
+ warnings.warn("The loop argument is deprecated since Python 3.8, "
+ "and scheduled for removal in Python 3.10.",
+ DeprecationWarning, stacklevel=2)
def __repr__(self):
res = super().__repr__()
@@ -317,10 +323,13 @@ class Condition(_ContextManagerMixin):
"""
def __init__(self, lock=None, *, loop=None):
- if loop is not None:
- self._loop = loop
- else:
+ if loop is None:
self._loop = events.get_event_loop()
+ else:
+ self._loop = loop
+ warnings.warn("The loop argument is deprecated since Python 3.8, "
+ "and scheduled for removal in Python 3.10.",
+ DeprecationWarning, stacklevel=2)
if lock is None:
lock = Lock(loop=self._loop)
@@ -445,10 +454,13 @@ class Semaphore(_ContextManagerMixin):
raise ValueError("Semaphore initial value must be >= 0")
self._value = value
self._waiters = collections.deque()
- if loop is not None:
- self._loop = loop
- else:
+ if loop is None:
self._loop = events.get_event_loop()
+ else:
+ self._loop = loop
+ warnings.warn("The loop argument is deprecated since Python 3.8, "
+ "and scheduled for removal in Python 3.10.",
+ DeprecationWarning, stacklevel=2)
def __repr__(self):
res = super().__repr__()
@@ -508,6 +520,11 @@ class BoundedSemaphore(Semaphore):
"""
def __init__(self, value=1, *, loop=None):
+ if loop:
+ warnings.warn("The loop argument is deprecated since Python 3.8, "
+ "and scheduled for removal in Python 3.10.",
+ DeprecationWarning, stacklevel=2)
+
self._bound_value = value
super().__init__(value, loop=loop)