fix: handle socket close errors properly in PapertrailLogHandler

- Replace contextlib.suppress with try/except + warning log
- Add test for fail2ban client
- Remove stale Issue #21 from Tasks.md (indexes)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-05-03 12:25:14 +02:00
parent 22db607875
commit 896751ada9
4 changed files with 43 additions and 46 deletions

View File

@@ -17,7 +17,6 @@ Usage::
from __future__ import annotations
import asyncio
import contextlib
import errno
import sys
import time
@@ -189,8 +188,15 @@ def _send_command_sync(
) from exc
finally:
if client is not None:
with contextlib.suppress(Exception):
try:
client.close()
except Exception as e:
log.warning(
"fail2ban_socket_close_error",
socket_path=socket_path,
error=str(e),
exc_info=True,
)
raise Fail2BanConnectionError(
str(last_oserror), socket_path