[ 
https://issues.apache.org/jira/browse/AIRFLOW-6208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16992122#comment-16992122
 ] 

ASF GitHub Bot commented on AIRFLOW-6208:
-----------------------------------------

konqui0 commented on pull request #6767: [AIRFLOW-6208] Implement fileno in 
StreamLogWriter
URL: https://github.com/apache/airflow/pull/6767
 
 
   ### Jira
   
   - [X] My PR addresses the following [Airflow 
Jira](https://issues.apache.org/jira/browse/AIRFLOW-6208) issues and references 
them in the PR title. 
   
   ### Description
   
   - [X] Here are some details about my PR, including screenshots of any UI 
changes:
   Tasks running with the python operator using subprocess.run fail when stdout 
is redirected to sys.stdout as the StreamLogWriter class does not implement the 
file descriptor return function fileno()
   
   `import sys
   import os
   subprocess.run("echo 1", shell=True, check=True, stdout=sys.stdout, 
stderr=sys.stderr)`
   
   `Traceback (most recent call last):
     File "/usr/lib/python3.8/site-packages/airflow/models/taskinstance.py", 
line 930, in _run_raw_task
       result = task_copy.execute(context=context)
     File 
"/usr/lib/python3.8/site-packages/airflow/operators/python_operator.py", line 
113, in execute
       return_value = self.execute_callable()
     File 
"/usr/lib/python3.8/site-packages/airflow/operators/python_operator.py", line 
118, in execute_callable
       return self.python_callable(*self.op_args, **self.op_kwargs)
     File "/home/sahas/airflow/dags/subprocess.py", line 39, in sp
       subprocess.run("echo 1", shell=True, check=True, stdout=sys.stdout, 
stderr=sys.stderr)
     File "/usr/lib/python3.8/subprocess.py", line 489, in run
       with Popen(*popenargs, **kwargs) as process:
     File "/usr/lib/python3.8/subprocess.py", line 804, in __init__
       errread, errwrite) = self._get_handles(stdin, stdout, stderr)
     File "/usr/lib/python3.8/subprocess.py", line 1487, in _get_handles
       c2pwrite = stdout.fileno()
   AttributeError: 'StreamLogWriter' object has no attribute 'fileno'`
   
   ### Tests
   
   - [X] My PR adds the following unit tests:
   
   Added:
   test_fileno in file tests/utils/test_logging_mixin.py
   
   ### Commits
   
   - [X] My commits all reference Jira issues in their subject lines, and I 
have squashed multiple commits if they address the same issue. In addition, my 
commits follow the guidelines from "[How to write a good git commit 
message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Documentation
   
   - [X] In case of new functionality, my PR adds documentation that describes 
how to use it.
     - All the public functions and the classes in the PR contain docstrings 
that explain what it does
     - If you implement backwards incompatible changes, please leave a note in 
the [Updating.md](https://github.com/apache/airflow/blob/master/UPDATING.md) so 
we can assign it to a appropriate release
   
 
----------------------------------------------------------------
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:
[email protected]


> StreamLogWriter class does not implement file fileno() function, preventing 
> output redirection to stdout with the python subprocess module
> ------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: AIRFLOW-6208
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-6208
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: logging
>    Affects Versions: 1.10.6
>         Environment: Archlinux python 3.8 Linux 5.4
> Also affects airflow breeze python 3.6 docker development environment
>            Reporter: Sahas L
>            Assignee: Sahas L
>            Priority: Major
>
> When using the python operator to execute a callbackfunction which makes use 
> of the subprocess module stdout redirection to system stdout, the task fails 
> due to fileno() being unimplemented in airflow/utils/log/logging_mixin.py 
> class StreamLogWriter.
> {code:java}
> Traceback (most recent call last):
>   File "/usr/lib/python3.8/site-packages/airflow/models/taskinstance.py", 
> line 930, in _run_raw_task
>     result = task_copy.execute(context=context)
>   File 
> "/usr/lib/python3.8/site-packages/airflow/operators/python_operator.py", line 
> 113, in execute
>     return_value = self.execute_callable()
>   File 
> "/usr/lib/python3.8/site-packages/airflow/operators/python_operator.py", line 
> 118, in execute_callable
>     return self.python_callable(*self.op_args, **self.op_kwargs)
>   File "/home/sahas/airflow/dags/subprocess.py", line 39, in sp
>     subprocess.run("echo 1", shell=True, check=True, stdout=sys.stdout, 
> stderr=sys.stderr)
>   File "/usr/lib/python3.8/subprocess.py", line 489, in run
>     with Popen(*popenargs, **kwargs) as process:
>   File "/usr/lib/python3.8/subprocess.py", line 804, in __init__
>     errread, errwrite) = self._get_handles(stdin, stdout, stderr)
>   File "/usr/lib/python3.8/subprocess.py", line 1487, in _get_handles
>     c2pwrite = stdout.fileno()
> AttributeError: 'StreamLogWriter' object has no attribute 'fileno'
> {code}
> The code in the callback function is:
> {code:java}
> import sys
> import os
> subprocess.run("echo 1", shell=True, check=True, stdout=sys.stdout, 
> stderr=sys.stderr)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to