multimodalart's picture
Update app.py
4d99b42 verified
raw
history blame
458 Bytes
import streamlit as st
import threading
import time
def long_running_task():
time.sleep(5)
@st.cache_resource
def get_global_lock():
return threading.Lock()
global_lock = get_global_lock()
# Add a button to start the task
if st.button('Start long running task'):
with global_lock:
with st.spinner("Running long running task"):
st.write("Task started")
long_running_task()
st.write("Task completed")