1

I have this program in which a progress bar is displayed to show the process of computation of the pe ratio and other metrics for a set of stocks, however sometimes the progress bar stops at a given iteration and resumes whenever I press the enter key. Here is a short description of what my code does:

from tqdm import tqdm

nb_stocks = 100
with tqdm(total=nb_stocks, desc="Computing stock metrics: ", leave=True) as pbar:
    for stock in stocks:
        ... # do stuff here
        pbar.update(1)

I tried asking LLMs about potential solutions they could provide but none of them had any idea of what was wrong with my code.

1 Answer 1

1
        ... # do stuff here
        pbar.update(1)

The "stuff" you execute has an input() call, or similar, which awaits hitting ENTER. The appearance of the bar won't change until "stuff" returns and pbar.update() gets to execute.

To debug this, temporarily remove the progress bar, as it is likely obscuring some prompting output from your "stuff" code.

Sign up to request clarification or add additional context in comments.

1 Comment

Do you mean my code calls input() directly, because I didn't use any in my code.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.