You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by "Sylwester Lachiewicz (Jira)" <ji...@apache.org> on 2026/09/08 14:39:00 UTC
[jira] [Resolved] (THRIFT-2975) Graceful handing of unexpected errors
[ https://issues.apache.org/jira/browse/THRIFT-2975?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sylwester Lachiewicz resolved THRIFT-2975.
------------------------------------------
Resolution: Fixed
The Python server loop handles unexpected errors gracefully: [lib/py/src/server/TServer.py|https://github.com/apache/thrift/blob/master/lib/py/src/server/TServer.py] catches TTransportException and has a general Exception handler that logs via logger.exception (lines 103-106) instead of dying. Resolving as Fixed.
> Graceful handing of unexpected errors
> -------------------------------------
>
> Key: THRIFT-2975
> URL: https://issues.apache.org/jira/browse/THRIFT-2975
> Project: Thrift
> Issue Type: Improvement
> Components: Python - Compiler
> Affects Versions: 0.9.2
> Reporter: Abhinav Gupta
> Priority: Major
>
> Currently, the Python compiler generate {{Processor.process_*}} methods that look something like,
> {code}
> def process_myMethod(...):
> myArg = ...
> try:
> result.success = self._handler.myMethod(myArg)
> except ExpectedException, e:
> result.exc = ...
> {code}
> If {{handler.myMethod}} throws an exception that was not defined in the service interface (due to a bug, for example), the client connection is terminated without any extra information being sent down. This is unideal because the client dos not know whether the issue was a networking error or a server-side problem.
> A possibly better behavior would be,
> {code}
> def process_myMethod(...):
> myArg = ...
> try:
> self._handler.myMethod(myArg)
> except ExpectedException, e:
> ...
> except Exception:
> exc = TApplicationException(INTERNAL_ERROR)
> # write exc to output protocol as an exception
> {code}
> The generated clients already expect {{TApplicationException}} in the response and know how to parse and handle them, so this won't require any change on the client side.
> Note that this will leave the connection open for further requests. My understanding is that there are some security concerns around that. So perhaps the behavior could be that {{process_*}} throws a {{TApplicationException}} and {{Processor.process}} catches it, sends it to the client and terminates the connection.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)