amaliujia commented on code in PR #40536:
URL: https://github.com/apache/spark/pull/40536#discussion_r1150013541
##########
python/pyspark/sql/connect/client.py:
##########
@@ -997,10 +1000,32 @@ def config(self, operation: pb2.ConfigRequest.Operation)
-> ConfigResult:
)
return ConfigResult.fromProto(resp)
raise SparkConnectException("Invalid state during retry exception
handling.")
- except grpc.RpcError as rpc_error:
- self._handle_error(rpc_error)
+ except Exception as error:
+ self._handle_error(error)
+
+ def _handle_error(self, error: Exception) -> NoReturn:
+ """
+ Handle errors that occur during RPC calls.
+
+ Parameters
+ ----------
+ error : Exception
+ An exception thrown during RPC calls.
+
+ Returns
+ -------
+ Throws the appropriate internal Python exception.
+ """
+ if isinstance(error, grpc.RpcError):
+ self._handle_rpc_error(cast(grpc.RpcError, error))
+ elif isinstance(error, ValueError):
+ if "Cannot invoke RPC" in str(error) and "closed" in str(error):
+ raise SparkConnectException(
+ error_class="NO_ACTIVE_SESSION", message_parameters=dict()
+ )
Review Comment:
I am thinking this will swallow other ValueError? You probably need to
re-throw non-closed channel ValueError?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]