kuroiikimono commited on
Commit
7d6381f
·
verified ·
1 Parent(s): cf2c550

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -44,7 +44,7 @@ def heart_beat():
44
  """
45
  Heartbeat function to track whether the session is alive
46
  """
47
- thread = threading.Timer(interval=2, function=heart_beat)
48
 
49
  # insert context to the current thread, needed for
50
  # getting session specific attributes like st.session_state
@@ -62,10 +62,9 @@ def heart_beat():
62
  logging.info(f"{ctx.session_id} is alive.")
63
  thread.start()
64
  else:
65
- print(st.session_state.uniq)
66
  if os.path.isdir(f"removefolder/{st.session_state.uniq}"):
67
  shutil.rmtree(f"removefolder/{st.session_state.uniq}")
68
- logging.info(f"{ctx.session_id} is gone.")
69
  return
70
 
71
  # JavaScript to detect browser exit
@@ -167,11 +166,11 @@ def main():
167
  ########
168
  reload_bt = st.empty()
169
  if reload_bt.button("Upload another PDF file"):
170
- for key in st.session_state.keys():
171
- if key == "count" or key == "temp" or key == "lang":
172
- continue
173
- else:
174
- del st.session_state[key]
175
  shutil.rmtree(f"removefolder/{temp_dir}")
176
  # page reload
177
  streamlit_js_eval(js_expressions="parent.window.location.reload()")
 
44
  """
45
  Heartbeat function to track whether the session is alive
46
  """
47
+ thread = threading.Timer(interval=5, function=heart_beat)
48
 
49
  # insert context to the current thread, needed for
50
  # getting session specific attributes like st.session_state
 
62
  logging.info(f"{ctx.session_id} is alive.")
63
  thread.start()
64
  else:
 
65
  if os.path.isdir(f"removefolder/{st.session_state.uniq}"):
66
  shutil.rmtree(f"removefolder/{st.session_state.uniq}")
67
+ logging.info(f"{ctx.session_id} is gone.")
68
  return
69
 
70
  # JavaScript to detect browser exit
 
166
  ########
167
  reload_bt = st.empty()
168
  if reload_bt.button("Upload another PDF file"):
169
+ #for key in st.session_state.keys():
170
+ # if key == "count" or key == "temp" or key == "lang":
171
+ # continue
172
+ # else:
173
+ # del st.session_state[key]
174
  shutil.rmtree(f"removefolder/{temp_dir}")
175
  # page reload
176
  streamlit_js_eval(js_expressions="parent.window.location.reload()")