Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make task output "unbuffered" so output is captured straight away #44186

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

ashb
Copy link
Member

@ashb ashb commented Nov 19, 2024

Without this change a dag like this:

@task()
def hello():
    print("hello")
    time.sleep(300)
    print("goodbye")

would not show the output for "hello" until after the sleep!

This is analogouys to setting PYTHONUNBUFFERED environment variable when
running something like python script.py | cat etc.

Without this change a dag like this:

```
@task()
def hello():
    print("hello")
    time.sleep(300)
    print("goodbye")
```

would not show the output for "hello" until after the sleep!

This is analogouys to setting PYTHONUNBUFFERED environment variable when
running something like `python script.py | cat` etc.
@ashb ashb added area:task-execution-interface-aip72 AIP-72: Task Execution Interface (TEI) aka Task SDK and removed area:task-sdk labels Nov 19, 2024
@ashb ashb merged commit 24811f7 into main Nov 19, 2024
42 checks passed
@ashb ashb deleted the task-sdk-proc-output-unbuffered branch November 19, 2024 13:42
print("stderr message", file=sys.stderr)
sys.stderr.flush()
# We need a short sleep for the main process to process things. I worry this timining will be
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# We need a short sleep for the main process to process things. I worry this timining will be
# We need a short sleep for the main process to process things. I worry this timing will be

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, just missed this by a few seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:task-execution-interface-aip72 AIP-72: Task Execution Interface (TEI) aka Task SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants