Skip to content

Commit 30b6fac

Browse files
Add more comments about wait_for releasing locks
1 parent b7f51bf commit 30b6fac

File tree

1 file changed

+5
-3
lines changed
  • python-packages/smithy-core/smithy_core/aio

1 file changed

+5
-3
lines changed

python-packages/smithy-core/smithy_core/aio/types.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ async def write(self, data: bytes) -> None:
319319
async with self._data_condition:
320320

321321
# Wait for the number of chunks in the buffer to be less than the
322-
# specified maximum. This also releases the lock until the condition
322+
# specified maximum. This also releases the lock until that condition
323323
# is met.
324324
await self._data_condition.wait_for(self._can_write)
325325

@@ -360,7 +360,8 @@ async def flush(self) -> None:
360360
# Block writes
361361
self._flushing = True
362362

363-
# Wait for the stream to be closed or for the data buffer to be empty.
363+
# Wait for the stream to be closed or for the data buffer to be empty,
364+
# releasing the lock until the condition is met.
364365
await self._data_condition.wait_for(lambda: len(self._data) == 0)
365366

366367
# Unblock writes
@@ -383,6 +384,7 @@ async def close(self, flush: bool = False) -> None:
383384
async with self._data_condition:
384385
self._closing = True
385386
if flush:
387+
# Release the lock until the buffer is empty.
386388
await self._data_condition.wait_for(lambda: len(self._data) == 0)
387389
else:
388390
# Clear out any pending data, freeing up memory.
@@ -403,7 +405,7 @@ async def __anext__(self) -> bytes:
403405
async with self._data_condition:
404406

405407
# Wait for the stream to be closed or for the data buffer to be non-empty.
406-
# This also releases the lock until the condition is met.
408+
# This also releases the lock until that condition is met.
407409
await self._data_condition.wait_for(
408410
lambda: self._closed or len(self._data) > 0
409411
)

0 commit comments

Comments
 (0)