]> git.ipfire.org Git - thirdparty/bind9.git/commit
Make exception/signal handlers idempotent
authorMichał Kępień <michal@isc.org>
Sun, 21 Dec 2025 05:25:56 +0000 (06:25 +0100)
committerMichał Kępień <michal@isc.org>
Sun, 21 Dec 2025 05:25:56 +0000 (06:25 +0100)
commit0ec94e501a04dc6a0730d75e6eeab2782202e16b
treed134bcb98eee99aae1e7c8b6030344674b4c7475
parent412862ce3046efbdd39054c7941c7113b81f83b1
Make exception/signal handlers idempotent

Calling asyncio.Future.set_exception() or asyncio.Future.set_result()
more than once for a given Future object raises an
asyncio.InvalidStateError exception.

In the case of AsyncServer:

  - it is enough to capture the first exception raised by higher-level
    logic as no exceptions at all are expected to be raised in the first
    place,

  - no distinction is made between SIGINT and SIGTERM; the only purpose
    of the signal handler is to make the server exit cleanly.

Given the above, make both AsyncServer._handle_exception() and
AsyncServer._signal_done() idempotent by ignoring
asyncio.InvalidStateError exceptions raised by the relevant
asyncio.Future.set_*() calls.
bin/tests/system/isctest/asyncserver.py