File size: 458 Bytes
d5826a0
 
 
 
 
 
 
 
 
 
 
 
 
1de1887
 
4d99b42
 
1de1887
 
4d99b42
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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")