Skip to content

Commit

Permalink
Merge pull request #337 from pipermerriam/piper/log-error-instead-of-…
Browse files Browse the repository at this point in the history
…crash-when-deadlocked

Log error instead of crash during deadlock
  • Loading branch information
pipermerriam committed Dec 19, 2020
2 parents 5738cd8 + 3583846 commit c11553a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ddht/v5_1/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,17 @@ async def _monitor_done(send_channel: trio.abc.SendChannel[ENRAPI]) -> None:
while True:
# this `fail_after` is a failsafe to prevent deadlock situations
# which are possible with `Condition` objects.
with trio.fail_after(60):
with trio.move_on_after(60) as scope:
node_ids = get_unqueried_node_ids()

if not node_ids and not in_flight:
break
else:
await condition.wait()

if scope.cancelled_caught:
network.logger.error("Deadlock")

send_channel, receive_channel = trio.open_memory_channel[ENRAPI](256)

async with trio.open_nursery() as nursery:
Expand Down

0 comments on commit c11553a

Please sign in to comment.