@@ -160,10 +160,13 @@ class Lock(_ContextManagerMixin):
160
160
def __init__ (self , * , loop = None ):
161
161
self ._waiters = None
162
162
self ._locked = False
163
- if loop is not None :
164
- self ._loop = loop
165
- else :
163
+ if loop is None :
166
164
self ._loop = events .get_event_loop ()
165
+ else :
166
+ self ._loop = loop
167
+ warnings .warn ("The loop argument is deprecated since Python 3.8, "
168
+ "and scheduled for removal in Python 3.10." ,
169
+ DeprecationWarning , stacklevel = 2 )
167
170
168
171
def __repr__ (self ):
169
172
res = super ().__repr__ ()
@@ -253,10 +256,13 @@ class Event:
253
256
def __init__ (self , * , loop = None ):
254
257
self ._waiters = collections .deque ()
255
258
self ._value = False
256
- if loop is not None :
257
- self ._loop = loop
258
- else :
259
+ if loop is None :
259
260
self ._loop = events .get_event_loop ()
261
+ else :
262
+ self ._loop = loop
263
+ warnings .warn ("The loop argument is deprecated since Python 3.8, "
264
+ "and scheduled for removal in Python 3.10." ,
265
+ DeprecationWarning , stacklevel = 2 )
260
266
261
267
def __repr__ (self ):
262
268
res = super ().__repr__ ()
@@ -317,10 +323,13 @@ class Condition(_ContextManagerMixin):
317
323
"""
318
324
319
325
def __init__ (self , lock = None , * , loop = None ):
320
- if loop is not None :
321
- self ._loop = loop
322
- else :
326
+ if loop is None :
323
327
self ._loop = events .get_event_loop ()
328
+ else :
329
+ self ._loop = loop
330
+ warnings .warn ("The loop argument is deprecated since Python 3.8, "
331
+ "and scheduled for removal in Python 3.10." ,
332
+ DeprecationWarning , stacklevel = 2 )
324
333
325
334
if lock is None :
326
335
lock = Lock (loop = self ._loop )
@@ -445,10 +454,13 @@ def __init__(self, value=1, *, loop=None):
445
454
raise ValueError ("Semaphore initial value must be >= 0" )
446
455
self ._value = value
447
456
self ._waiters = collections .deque ()
448
- if loop is not None :
449
- self ._loop = loop
450
- else :
457
+ if loop is None :
451
458
self ._loop = events .get_event_loop ()
459
+ else :
460
+ self ._loop = loop
461
+ warnings .warn ("The loop argument is deprecated since Python 3.8, "
462
+ "and scheduled for removal in Python 3.10." ,
463
+ DeprecationWarning , stacklevel = 2 )
452
464
453
465
def __repr__ (self ):
454
466
res = super ().__repr__ ()
@@ -508,6 +520,11 @@ class BoundedSemaphore(Semaphore):
508
520
"""
509
521
510
522
def __init__ (self , value = 1 , * , loop = None ):
523
+ if loop :
524
+ warnings .warn ("The loop argument is deprecated since Python 3.8, "
525
+ "and scheduled for removal in Python 3.10." ,
526
+ DeprecationWarning , stacklevel = 2 )
527
+
511
528
self ._bound_value = value
512
529
super ().__init__ (value , loop = loop )
513
530
0 commit comments