streamlit-extras icon indicating copy to clipboard operation
streamlit-extras copied to clipboard

Add concurrency_limiter

Open kajarenc opened this issue 11 months ago • 1 comments

A concurrency limiter decorator could be used to limit the concurrent execution of functions. Could be useful for heavy computation/memory tasks, or when a task to requests to API with rate limits.

@concurrency_limiter(max_concurrency=1)
def heavy_computation():
    st.write("Heavy computation")
    progress_text = "Operation in progress. Please wait."
    my_bar = st.progress(0, text=progress_text)

    for percent_complete in range(100):
        time.sleep(0.15)
        my_bar.progress(percent_complete + 1, text=progress_text)
    st.write("END OF Heavy computation")
    return 42


my_button = st.button("Run heavy computation")

kajarenc avatar Mar 22 '24 13:03 kajarenc

Deploy Preview for phenomenal-crepe-0effec ready!

Name Link
Latest commit 8d23420b323c14c947bc15e633bbb6285a5aea84
Latest deploy log https://app.netlify.com/sites/phenomenal-crepe-0effec/deploys/6629148b298fe400081ddca2
Deploy Preview https://deploy-preview-223--phenomenal-crepe-0effec.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Mar 22 '24 13:03 netlify[bot]