Flushing to the console doesn't produce immediate output from Python

Problem description

When I try to flush to the console for immediate output like this:

print('Loading records....', flush=True)
conn = connect(environ['DB_CONNECT']) 
...
print('...records loaded.')

Neither message doesn’t appear until the database connection is opened.

Expected behavior

print('foo', flush=True) should print to the console immediately.

Actual behavior

It does not.

Steps to reproduce

Create a new python repl, and try this:

from time import sleep
print('foo', flush=True)
sleep(10) 
print('bar')

Note that foo and bar appear at the same time in the console, after 10 seconds.

Browser

Chrome

OS

ChromeOS

Device if mobile

also occurs update: used to occur on Android mobile app

Plan

Core membership

Same on mobile, by the way. (Android) Fixed on Android mobile app now!

1 Like

Can’t reproduce it, could you please try to send the whole code for the first example?

1 Like

why are you flushing, anyway?

1 Like

Because I want to see output without a delay. (I mean, why does anyone flush?)

Does https://replit.com/@jsalsman/BugTest print foo immediately, not after 10 seconds for you? If so, do you have custom settings perhaps, somehow? The first example is from a 100+ line program which needs sensitive secrets to run.

foo is printed instantly for me. But can’t you just run without the flush?

from time import sleep
print('foo')
sleep(10) 
print('bar')

That also gives me a 10 second delay before seeing foo and bar. Do you have some sort of custom settings?

1 Like

any settings that could affect this would be per-repl… I have no idea, honestly. could you send a video of the issue, try with a different account, etc.?

Video here: Watch Screen recording 2024-04-24 7.47.14 PM | Streamable

I suggest trying another account can’t solve my problem for the private shared repls I’m deeply involved with collaborating on. As you can see from the comments above, some people can reproduce it and some people can’t.

Maybe, but it might help to figure out the bug.

Created @testrepl2 from incognito mode and forked https://replit.com/@testrepl2/BugTest – problem still occurs.

1 Like

This just in: it is working correctly on Android mobile app now, but wasn’t earlier. I hope that means someone is working on it!

…Still failing on Chrome though.

1 Like

Ah, both are appearing, but you’re having the zoom issue. Could you try only printing the first one, and then adjusting browser zoom until it appears?

2 Likes

Yes, adjusting the browser zoom makes ‘foo’ appear briefly and then it disappears until the 10 seconds are up. What is the zoom issue?

A recent known bug where browser zoom affects visibility of logs in the console, Replit Staff is aware of the problem.

2 Likes