Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/4601#discussion_r24785741
--- Diff: core/src/main/scala/org/apache/spark/api/python/PythonRDD.scala
---
@@ -144,11 +144,24 @@ private[spark] class PythonRDD(
stream.readFully(update)
accumulator += Collections.singletonList(update)
}
+
// Check whether the worker is ready to be re-used.
- if (stream.readInt() == SpecialLengths.END_OF_STREAM) {
- if (reuse_worker) {
- env.releasePythonWorker(pythonExec, envVars.toMap,
worker)
- released = true
+ if (reuse_worker) {
+ // It has a high possibility that the ending mark is
already available,
+ // And current task should not be blocked by checking it
+
+ if (stream.available() >= 4) {
+ val ending = stream.readInt()
+ if (ending == SpecialLengths.END_OF_STREAM) {
+ env.releasePythonWorker(pythonExec, envVars.toMap,
worker)
+ released = true
+ logInfo(s"Socket is ended cleanly, reuse it: $worker")
--- End diff --
Worker does not exit, it will be reused.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]