You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a bug in the Python integration that needs to be addressed.
When running the following command:
llgo run ./_pydemo/callpy/
The output is displayed correctly. However, when running:
llgo run ./_pydemo/callpy/ > output.txt && cat output.txt
There is no output.
Root cause
The root cause of this issue appears to be related to Python's default buffering mode. By default, Python uses buffered I/O for sys.stdin, sys.stdout, and sys.stderr.
In the 1st case, the output is shown in the console because it uses line buffering.
In the 2nd case, the output is not captured in output.txt because it uses full buffering, and the buffer is not flushed before the program exits.
Workarounds
The issue can be temporarily fixed by disabling Python's buffering mode manually:
export PYTHONUNBUFFERED=1
Possible solutions
To resolve this issue in llgo,
it may be necessary to switch Python to unbuffered mode;
or provide a manual flush option, though this could be cumbersome for users;
or ensure the buffer is flushed before the program exits to retain Python's default design.
For reference, Go's os.Stdin, os.Stdout, and os.Stderr are always unbuffered (see: golang-nuts).
The text was updated successfully, but these errors were encountered:
Description
There is a bug in the Python integration that needs to be addressed.
When running the following command:
The output is displayed correctly. However, when running:
There is no output.
Root cause
The root cause of this issue appears to be related to Python's default buffering mode. By default, Python uses buffered I/O for
sys.stdin
,sys.stdout
, andsys.stderr
.output.txt
because it uses full buffering, and the buffer is not flushed before the program exits.Workarounds
The issue can be temporarily fixed by disabling Python's buffering mode manually:
export PYTHONUNBUFFERED=1
Possible solutions
To resolve this issue in llgo,
For reference, Go's
os.Stdin
,os.Stdout
, andos.Stderr
are always unbuffered (see: golang-nuts).The text was updated successfully, but these errors were encountered: