print() won't flush until whole function finished

Bug #1569808 reported by Yung Shen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PlainBox (Toolkit)
Invalid
Low
Unassigned

Bug Description

If you run following codes within plainbox job, the countdown numbers will not show up in each iteration until whole loop finished:

for i in range(10):
    print(i, end="\r", flush=True)
    time.sleep(0.5)

summary: - print() won't flush until whole function finishedprint() won't flush
- until whole for-loop finished
+ print() won't flush until whole function finished
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

I you prefix the job command with PYTHONUNBUFFERED=1 you should get the desired behaviour.

Changed in plainbox:
status: New → Triaged
importance: Undecided → Medium
assignee: nobody → Sylvain Pineau (sylvain-pineau)
milestone: none → 0.28
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :
Revision history for this message
Yung Shen (kaxing) wrote :

Try to use this way:
command: export PYTHONUNBUFFERED=1; the_script

But still buffered.

Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

and with the following syntax:

PYTHONUNBUFFERED=1 bt_connect --mouse

Revision history for this message
Yung Shen (kaxing) wrote :

I actually tried both, with and without export and no semicolon, but still buffered.
As in contrast, running the script directly, won't be any problem.

Pierre Equoy (pieq)
Changed in plainbox:
milestone: 0.28 → 0.29
Changed in plainbox:
importance: Medium → Low
milestone: 0.29 → future
Changed in plainbox:
assignee: Sylvain Pineau (sylvain-pineau) → nobody
Changed in plainbox:
status: Triaged → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.