allisonwang-db commented on code in PR #40536:
URL: https://github.com/apache/spark/pull/40536#discussion_r1150302155
##########
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:
Yea it can throw other `ValueError`s. And here is what it looks like in
console:
```
pyspark.errors.exceptions.connect.SparkConnectException: [NO_ACTIVE_SESSION]
No active Spark session found. Please create a new Spark session before running
the code.
```
To verify this, I manually changed the code to throw a ValueError. Is there
a way to trigger other GRPC Cannot invoke RPC errors?
--
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]