Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/services/delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,10 @@ async def _run(self) -> None:
if timeout is None:
await self._wake.wait()
else:
await asyncio.wait_for(self._wake.wait(), timeout)
# asyncio.timeout, not wait_for: on Python 3.11 wait_for can swallow a
# cancellation, and stop() would then wait for this loop forever.
async with asyncio.timeout(timeout):
await self._wake.wait()
except TimeoutError:
timed_out = True
self._wake.clear()
Expand Down
5 changes: 4 additions & 1 deletion app/services/ephemeral.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,10 @@ def _timeout(self) -> float:
async def _run(self) -> None:
while True:
with contextlib.suppress(TimeoutError):
await asyncio.wait_for(self._wake.wait(), self._timeout())
# asyncio.timeout, not wait_for: on Python 3.11 wait_for can swallow a
# cancellation, and stop() would then wait for this loop forever.
async with asyncio.timeout(self._timeout()):
await self._wake.wait()
self._wake.clear()
try:
await self.expire_if_due()
Expand Down