8000 make patchcheck · python/cpython@7dfa8ef · GitHub
[go: up one dir, main page]

Skip to content

Commit 7dfa8ef

Browse files
committed
make patchcheck
Change after run make patchcheck
1 parent 2cd5ce0 commit 7dfa8ef

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

Lib/asyncio/locks.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def release(self):
433433
# and a 'broken' state in which all tasks get the exception.
434434

435435
class Barrier(mixins._LoopBoundMixin):
436-
"""Asynchronous equivalent to threading.Barrier
436+
"""Asynchronous equivalent to threading.Barrier
437437
438438
Implements a Barrier.
439439
Useful for synchronizing a fixed number of tasks at known synchronization
@@ -445,18 +445,18 @@ def __init__(self, parties, action=None, *, loop=mixins._marker):
445445
"""Create a barrier, initialised to 'parties' tasks.
446446
'action' is a callable which, when supplied, will be called by one of
447447
the tasks after they have all entered the barrier and just prior to
448-
releasing them all.
448+
releasing them all.
449449
"""
450450
super().__init__(loop=loop)
451451
if parties < 1:
452452
raise ValueError('parties must be > 0')
453453

454454
self._waiting = Event() # used notify all waiting tasks
455-
self._blocking = Event() # used block tasks while wainting tasks are draining or broken
455+
self._blocking = Event() # used block tasks while wainting tasks are draining or broken
456456
self._action = action
457457
self._parties = parties
458458
self._state = 0 # 0 filling, 1, draining, -1 resetting, -2 broken
459-
self._count = 0 # count waiting tasks
459+
self._count = 0 # count waiting tasks
460460

461461
def __repr__(self):
462462
res = super().__repr__()
@@ -494,7 +494,7 @@ async def _block (self):
494494
if self._state in (-1, 1):
495495
# It is draining or resetting, wait until done
496496
await self._blocking.wait()
497-
497+
498498
#see if the barrier is in a broken state
499499
if self._state < 0:
500500
raise BrokenBarrierError
@@ -515,7 +515,7 @@ def _release(self):
515515
self._state = -2
516516
self._blocking.clear()
517517
self._waiting.set()
518-
raise
518+
raise
519519

520520
# Wait in the barrier until we are released. Raise an exception
521521
# if the barrier is reset or broken.
@@ -529,7 +529,7 @@ async def _wait(self):
529529
# If we are the last tasks to exit the barrier, signal any tasks
530530
# waiting for the barrier to drain.
531531
def _exit(self):
532-
if self._count == 0:
532+
if self._count == 0:
533533
if self._state == 1:
534534
self._state = 0
535535
elif self._state == -1:
@@ -543,7 +543,7 @@ def reset(self):
543543
Any tasks currently waiting will get the BrokenBarrier exception
544544
raised.
545545
"""
546-
if self._count > 0:
546+
if self._count > 0:
547547
if self._state in (0, 1):
548548
#reset the barrier, waking up tasks
549549
self._state = -1
@@ -588,4 +588,4 @@ def broken(self):
588588

589589
# exception raised by the Barrier class
590590
class BrokenBarrierError(RuntimeError):
591-
pass
591+
pass

Lib/test/test_asyncio/test_locks.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def test_lock_doesnt_accept_loop_parameter(self):
7070
):
7171
cls(loop=self.loop)
7272

73-
# Barrier object has a positional paramater
74-
# so check alone
73+
# Barrier object has a positional paramater
74+
# so check alone
7575
cls = asyncio.Barrier
7676
with self.assertRaisesRegex(
7777
TypeError,
@@ -947,7 +947,7 @@ class BarrierTests(test_utils.TestCase):
947947
def setUp(self):
948948
super().setUp()
949949
self.loop = self.new_test_loop()
950-
self.N = 5
950+
self.N = 5
951951

952952
async def run_coros(self, n, coro):
953953
tasks = [self.loop.create_task(coro()) for _ in range(n)]
@@ -969,8 +969,8 @@ async def coro():
969969
self.assertTrue(f"count:0/{str(self.N)}" in repr(barrier))
970970
self.assertTrue(RGX_REPR.match(repr(barrier)))
971971
self.assertTrue(repr(barrier).endswith('unset, state:0]>'))
972-
973-
nb_waits = 3
972+
973+
nb_waits = 3
974974
tasks = []
975975
for _ in range(nb_waits):
976976
tasks.append(self.loop.create_task(coro()))
@@ -1002,16 +1002,16 @@ def test_init(self):
10021002
se 9E81 lf.assertRaises(ValueError, lambda: asyncio.Barrier(0))
10031003
self.assertRaises(ValueError, lambda: asyncio.Barrier(-4))
10041004

1005-
def test_wait(self):
1005+
def test_wait_more(self):
10061006
async def coro(result):
10071007
r = await barrier.wait()
10081008
result.append(r)
1009-
1009+
10101010
barrier = asyncio.Barrier(self.N)
10111011
results = []
10121012
_ = [self.loop.create_task(coro(results)) for _ in range(self.N)]
10131013
test_utils.run_briefly(self.loop)
1014-
self.assertEqual(sum(results), sum(range(self.N)))
1014+
self.assertEqual(sum(results), sum(range(self.N)))
10151015
self.assertFalse(barrier.broken)
10161016

10171017
def test_wait_task_multi(self):
@@ -1029,7 +1029,7 @@ def test_wait_task_multi(self):
10291029
self.assertEqual(barrier.n_waiting, 0)
10301030
self.assertFalse(barrier.broken)
10311031

1032-
def test_wait_task(self):
1032+
def test_wait_task_one(self):
10331033
self.N = 1
10341034
barrier = asyncio.Barrier(self.N)
10351035
r1 = self.loop.run_until_complete(barrier.wait())
@@ -1115,7 +1115,7 @@ async def coro(result, value):
11151115
value = 1
11161116
barrier = asyncio.Barrier(1, action=lambda: result1.append(True))
11171117
_ = [self.loop.create_task(coro(result, value)) for _ in range(self.N)]
1118-
test_utils.run_briefly(self.loop)
1118+
test_utils.run_briefly(self.loop)
11191119

11201120
self.assertEqual(len(result1), self.N)
11211121
self.assertTrue(all(result1))
@@ -1134,7 +1134,7 @@ async def coro(result, value):
11341134
value = 1
11351135
barrier = asyncio.Barrier(self.N, action=lambda: result1.append(True))
11361136
_ = [self.loop.create_task(coro(result, value)) for _ in range(self.N)]
1137-
test_utils.run_briefly(self.loop)
1137+
test_utils.run_briefly(self.loop)
11381138

11391139
self.assertEqual(len(result1), 1)
11401140
self.assertTrue(result1[0])
@@ -1173,9 +1173,9 @@ def test_reset(self):
11731173
results1 = []
11741174
results2 = []
11751175
async def coro():
1176-
try:
1176+
try:
11771177
await barrier.wait()
1178-
except asyncio.BrokenBarrierError:
1178+
except asyncio.BrokenBarrierError:
11791179
results1.append(True)
11801180
finally:
11811181
await barrier.wait()
@@ -1217,7 +1217,7 @@ async def coro():
12171217
# Now, pass the barrier again
12181218
await barrier1.wait()
12191219
results3.append(True)
1220-
1220+
12211221
barrier = asyncio.Barrier(self.N)
12221222
barrier1 = asyncio.Barrier(self.N)
12231223
res, tasks = self.loop.run_until_complete(self.run_coros(self.N, coro))
@@ -1235,7 +1235,7 @@ async def coro():
12351235
if i == self.N//2:
12361236
raise RuntimeError
12371237
await barrier.wait()
1238-
results1.append(True)
1238+
results1.append(True)
12391239
except asyncio.BrokenBarrierError:
12401240
results2.append(True)
12411241
except RuntimeError:
@@ -1272,7 +1272,7 @@ async def coro():
12721272
await barrier2.wait()
12731273
await barrier.wait()
12741274
results3.append(True)
1275-
1275+
12761276
barrier = asyncio.Barrier(self.N)
12771277
barrier2 = asyncio.Barrier(self.N)
12781278
res, tasks = self.loop.run_until_complete(self.run_coros(self.N, coro))

0 commit comments

Comments
 (0)
0