multimodalart HF Staff commited on
Commit
1de1887
·
verified ·
1 Parent(s): d5826a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -12
app.py CHANGED
@@ -2,24 +2,19 @@ import streamlit as st
2
  import threading
3
  import time
4
 
5
-
6
  def long_running_task():
7
  time.sleep(5)
8
 
9
-
10
  @st.cache_resource
11
  def get_global_lock():
12
  return threading.Lock()
13
 
14
-
15
  global_lock = get_global_lock()
16
 
17
-
18
- st.write("This is a long running task")
19
-
20
- with st.spinner("Running long running task"):
21
- with global_lock:
22
- st.write("Task started")
23
- long_running_task()
24
-
25
- st.write("Task completed")
 
2
  import threading
3
  import time
4
 
 
5
  def long_running_task():
6
  time.sleep(5)
7
 
 
8
  @st.cache_resource
9
  def get_global_lock():
10
  return threading.Lock()
11
 
 
12
  global_lock = get_global_lock()
13
 
14
+ # Add a button to start the task
15
+ if st.button('Start long running task'):
16
+ with st.spinner("Running long running task"):
17
+ with global_lock:
18
+ st.write("Task started")
19
+ long_running_task()
20
+ st.write("Task completed")