RamonZhou commented on code in PR #58396:
URL: https://github.com/apache/spark/pull/58396#discussion_r4446112306
##########
python/pyspark/sql/tests/connect/client/test_client.py:
##########
@@ -745,6 +878,52 @@ def mock_close():
self.assertEqual(call_tracker["release_session"], 1)
self.assertEqual(call_tracker["close"], 1)
+ def test_on_exit_sends_no_rpc_without_live_session(self):
+ """Test _on_exit sends no RPC for a session that was never established
or was released.
+
+ RPCs are recorded at the stub, so any new exit-time RPC is covered,
not only the ones
+ _on_exit sends today.
+ """
+
+ def exit_rpcs(observed_id, release_on_exit, release_first=False,
release_id=""):
+ client = SparkConnectClient("sc://foo/",
use_reattachable_execute=False)
+ # Use the real ML cache cleanup, which this module patches out,
and keep the atexit
+ # hook from running it again at interpreter exit.
+ client._cleanup_ml_cache = _real_cleanup_ml_cache.__get__(client)
+ self.addCleanup(setattr, client, "_closed", True)
Review Comment:
Fixed as suggested!
##########
python/pyspark/sql/tests/connect/client/test_client.py:
##########
@@ -745,6 +878,52 @@ def mock_close():
self.assertEqual(call_tracker["release_session"], 1)
self.assertEqual(call_tracker["close"], 1)
+ def test_on_exit_sends_no_rpc_without_live_session(self):
Review Comment:
Added a stub-level test
--
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]