Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore internal ConnectionResetErrors #8404

Merged
merged 1 commit into from
Jan 21, 2025
Merged
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
10 changes: 7 additions & 3 deletions src/tribler/core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from contextlib import contextmanager
from os.path import isfile
from traceback import format_exception
from typing import TYPE_CHECKING, Any, Generator, Type, cast
from typing import TYPE_CHECKING, Any, cast

import aiohttp
from ipv8.keyvault.crypto import default_eccrypto
Expand Down Expand Up @@ -43,6 +43,7 @@
from tribler.core.socks5.server import Socks5Server

if TYPE_CHECKING:
from collections.abc import Generator
from types import TracebackType

from tribler.core.database.store import MetadataStore
Expand Down Expand Up @@ -177,7 +178,7 @@ def register_rest_endpoints(self) -> None:
self.rest_manager.add_endpoint(StatisticsEndpoint())
self.rest_manager.add_endpoint(TorrentInfoEndpoint(self.download_manager))

def _except_hook(self, typ: Type[BaseException], value: BaseException, traceback: TracebackType | None) -> None:
def _except_hook(self, typ: type[BaseException], value: BaseException, traceback: TracebackType | None) -> None:
"""
Handle an uncaught exception.

Expand All @@ -196,7 +197,10 @@ def _asyncio_except_hook(self, loop: AbstractEventLoop, context: dict[str, Any])
Note2: ignored BaseExceptions are BaseExceptionGroup, GeneratorExit, KeyboardInterrupt and SystemExit
"""
exc = context.get("exception")
if isinstance(exc, Exception):
if isinstance(exc, ConnectionResetError):
logger.exception("Network unreachable: %s",
"".join(format_exception(exc.__class__, exc, exc.__traceback__)))
elif isinstance(exc, Exception):
logger.exception("Uncaught async exception: %s",
"".join(format_exception(exc.__class__, exc, exc.__traceback__)))
cast(EventsEndpoint, self.rest_manager.get_endpoint("/api/events")).on_tribler_exception(exc)
Expand Down
Loading