multimodalart's picture
Update app.py
b0e99d1 verified
raw
history blame contribute delete
459 Bytes
import streamlit as st
import threading
import time
def long_running_task():
time.sleep(15)
@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")