You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/10/22 18:01:55 UTC

[GitHub] [airflow] mik-laj commented on a change in pull request #6389: [AIRFLOW-5663]: Switch to real-time logging in PythonVirtualenvOperator.

mik-laj commented on a change in pull request #6389: [AIRFLOW-5663]: Switch to real-time logging in PythonVirtualenvOperator.
URL: https://github.com/apache/airflow/pull/6389#discussion_r337667617
 
 

 ##########
 File path: airflow/operators/python_operator.py
 ##########
 @@ -330,16 +330,20 @@ def _pass_op_args(self):
         return len(self.op_args) + len(self.op_kwargs) > 0
 
     def _execute_in_subprocess(self, cmd):
-        try:
-            self.log.info("Executing cmd\n%s", cmd)
-            output = subprocess.check_output(cmd,
-                                             stderr=subprocess.STDOUT,
-                                             close_fds=True)
-            if output:
-                self.log.info("Got output\n%s", output)
-        except subprocess.CalledProcessError as e:
-            self.log.info("Got error output\n%s", e.output)
-            raise
+        self.log.info("Executing cmd\n{}".format(cmd))
+        self._sp = subprocess.Popen(cmd,
+                                    stdout=subprocess.PIPE,
+                                    stderr=subprocess.STDOUT,
+                                    bufsize=0,
+                                    close_fds=True)
+        self.log.info("Got output\n")
+        with self._sp.stdout:
+            for line in iter(self._sp.stdout.readline, b''):
+                self.log.info(line)
 
 Review comment:
   ```suggestion
                   self.log.info("%s", line)
   ```
   Data should be passed as arguments so that they are written in a different color.

----------------------------------------------------------------
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