How to display progress bar corresponding to the number of things downloaded parallely?

I am building an app with streamlit and it works in the following way:

  1. The user enters a query that he/she wants to search
  2. Enters the max number of papers he/she wants to download
  3. The search module (which is also developed & managed by me, and has been installed using pip) takes the query and searches for papers and downloads them

Currently, I am printing the number of papers being downloaded as follows:

enter image description here

In the image above, even though it shows 4097 pages to download, if the user limits the downloading to say 10 papers, only 10 will be downloaded.

Now, I am trying to display this information in the form of a progress bar using the stqdm library. I am unable to figure out how can I implement it since the frontend is built using streamlit & the backend code is run using a separate module.

My codes so far:

Codes in the streamlit app:

import streamlit as st
import my_search_module as sm

st.write("Please wait till the results are obtained")
search =, limit=10)

The simplified code in the my_search_module:

def search(query: str, limit: int):
    papers_count = 0
    # this url gets all the total number of papers to download
    url = f"some_url&query={query}"
    total_papers = requests.get(url)
    while papers_count < limit:
        if papers_count >= limit:
        papers_count += 1
            # some function with a diff url that starts downloading the papers
        except Exception as e:

While this code in the search function is being run and the papers_count variable keeps increasing, I want to display this increment also in the frontend.

How can this be achieved?

Thanks in advance.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.