Bug report
Bug description:
asyncio.Lock._wake_up_first contains an unreachable try/except StopIteration block:
def _wake_up_first(self):
"""Ensure that the first waiter will wake up."""
if not self._waiters:
return
try:
fut = next(iter(self._waiters))
except StopIteration:
return
...
Early return at if not self._waiters already gurantees that self._waiters is not an empty collections.deque. next(iter(deque)) on cannot raise StopIteration, so there is unreachable dead code.
Proposed change:
def _wake_up_first(self):
"""Ensure that the first waiter will wake up."""
if not self._waiters:
return
fut = next(iter(self._waiters))
# .done() means that the waiter is already set to wake up.
if not fut.done():
fut.set_result(True)
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
Bug report
Bug description:
asyncio.Lock._wake_up_firstcontains an unreachabletry/except StopIterationblock:Early return at
if not self._waitersalready gurantees thatself._waitersis not an emptycollections.deque.next(iter(deque))on cannot raiseStopIteration, so there is unreachable dead code.Proposed change:
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs