HyukjinKwon commented on code in PR #56676:
URL: https://github.com/apache/spark/pull/56676#discussion_r3455713211
##########
python/pyspark/resource/tests/test_connect_resources.py:
##########
@@ -46,6 +46,17 @@ def test_profile_before_sc_for_connect(self):
).getOrCreate()
# Still can access taskResources, similar to executorResources.
self.assertEqual(rp.taskResources["cpus"].amount, 2.0)
+ # SPARK-57615: the local-cluster Spark Connect server can return
errors on the first
+ # commands right after start-connect-server.sh returns, before its
SparkContext is fully
+ # initialized. Wait until a trivial job succeeds before creating a
ResourceProfile, which
+ # would otherwise race that initialization and fail server-side.
+ from pyspark.testing.utils import eventually
+
+ def _server_ready() -> bool:
+ spark.range(1).count()
+ return True
+
+ eventually(timeout=120,
expected_exceptions=(Exception,))(_server_ready)()
Review Comment:
Good point - narrowed it to `PySparkException` (the base class of the
`SparkConnect*` exceptions the not-yet-ready server raises) instead of bare
`Exception`.
I kept it at the `PySparkException` level rather than a specific
`SparkConnect*` subclass for two reasons: (1) importing the connect-specific
exception at module top-level would require grpc and break test collection on
grpc-less builds, and (2) the not-ready server can surface the race as a few
different `SparkConnect*` subclasses, so narrowing further risks not retrying
the very error we're guarding against. Also moved the `eventually` import up to
the module-level imports.
--
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]