trino-python-client icon indicating copy to clipboard operation
trino-python-client copied to clipboard

Add `flush=True` to `ConsoleRedirectHandler` print statements

Open mcgr0g opened this issue 8 months ago • 3 comments

Describe the feature

When using the ConsoleRedirectHandler for OAuth flows, the printed authentication URL sometimes doesn't appear immediately in VS Code terminal outputs (particularly when called through extensions like dbt Power User). This occurs because:

  1. The current implementation doesn't force flush the output buffer (auth.py#L286)
  2. Some IDE/plugin terminal implementations buffer stdout differently than standalone terminals

Request to modify the print statement to:

print(f"Open the following URL in browser for the external authentication: {url}", flush=True)

Describe alternatives you've considered

Waiting for fixes in downstream tools (vscode-dbt-power-user#1629)

Are you willing to submit PR?

  • [x] Yes I am willing to submit a PR!

mcgr0g avatar Apr 01 '25 19:04 mcgr0g

Thanks for the explanation. This makes sense (and it's unexpected that writes to stdout will get bufferred).

It looks like a simple change, are you willing to submit a PR @mcgr0g ?

hashhar avatar Apr 10 '25 09:04 hashhar

I’ve created a PR for this issue. @hashhar , please review when you have time.

mcgr0g avatar Apr 17 '25 21:04 mcgr0g

@hashhar Hi! Any update on this?

DenGodunov avatar Apr 25 '25 10:04 DenGodunov