You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/06/07 02:47:32 UTC

[GitHub] [spark] HyukjinKwon commented on a change in pull request #24811: [SPARK-27962][R][CORE] Propagate subprocess stdout in deploy.RRunner in exception

HyukjinKwon commented on a change in pull request #24811: [SPARK-27962][R][CORE] Propagate subprocess stdout in deploy.RRunner in exception
URL: https://github.com/apache/spark/pull/24811#discussion_r291437528
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/deploy/RRunner.scala
 ##########
 @@ -100,15 +100,17 @@ object RRunner {
         builder.redirectErrorStream(true) // Ugly but needed for stdout and stderr to synchronize
         val process = builder.start()
 
-        new RedirectThread(process.getInputStream, System.out, "redirect R output").start()
+        val stdoutBuffer = new CircularBuffer(1024)
+        val output = new TeeOutputStream(System.out, stdoutBuffer)
+        new RedirectThread(process.getInputStream, output, "redirect R output").start()
 
-        process.waitFor()
+        val returnCode = process.waitFor()
+        if (returnCode != 0) {
+          throw SparkUserAppException(returnCode, Option(stdoutBuffer.toString))
+        }
       } finally {
         sparkRBackend.close()
       }
-      if (returnCode != 0) {
 
 Review comment:
   @jeremyjliu, can you show before/after error messages? Seems like we redirect stderr. Doesn't that work?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org