Update app.py
Browse files
app.py
CHANGED
@@ -189,9 +189,9 @@ def read_email():
|
|
189 |
except Exception as e:
|
190 |
logger.error(f"Error reading emails: {e}")
|
191 |
|
192 |
-
# Email processing loop
|
193 |
running = False
|
194 |
-
loop_thread = None
|
195 |
|
196 |
# Dummy function to simulate email processing (replace with actual email processing code)
|
197 |
def email_processing_loop():
|
@@ -208,14 +208,14 @@ def start_processing():
|
|
208 |
running = True
|
209 |
loop_thread = threading.Thread(target=email_processing_loop, daemon=True)
|
210 |
loop_thread.start()
|
211 |
-
return
|
212 |
|
213 |
# Stop the email processing loop
|
214 |
def stop_processing():
|
215 |
global running
|
216 |
if running:
|
217 |
running = False
|
218 |
-
return
|
219 |
|
220 |
# Update the status of email processing
|
221 |
def update_status():
|
@@ -234,9 +234,8 @@ with gr.Blocks() as demo:
|
|
234 |
start_button.click(fn=start_processing, outputs=status_display)
|
235 |
stop_button.click(fn=stop_processing, outputs=status_display)
|
236 |
|
237 |
-
#
|
238 |
-
|
239 |
-
timer.every(fn=update_status, outputs=status_display)
|
240 |
|
241 |
if __name__ == "__main__":
|
242 |
logging.info('Starting project...')
|
|
|
189 |
except Exception as e:
|
190 |
logger.error(f"Error reading emails: {e}")
|
191 |
|
192 |
+
# Email processing loop variables
|
193 |
running = False
|
194 |
+
loop_thread = None
|
195 |
|
196 |
# Dummy function to simulate email processing (replace with actual email processing code)
|
197 |
def email_processing_loop():
|
|
|
208 |
running = True
|
209 |
loop_thread = threading.Thread(target=email_processing_loop, daemon=True)
|
210 |
loop_thread.start()
|
211 |
+
return update_status()
|
212 |
|
213 |
# Stop the email processing loop
|
214 |
def stop_processing():
|
215 |
global running
|
216 |
if running:
|
217 |
running = False
|
218 |
+
return update_status()
|
219 |
|
220 |
# Update the status of email processing
|
221 |
def update_status():
|
|
|
234 |
start_button.click(fn=start_processing, outputs=status_display)
|
235 |
stop_button.click(fn=stop_processing, outputs=status_display)
|
236 |
|
237 |
+
# Add a manual timer without the interval parameter
|
238 |
+
gr.Timer.every(2, fn=update_status, outputs=status_display) # Run `update_status()` every 2 seconds
|
|
|
239 |
|
240 |
if __name__ == "__main__":
|
241 |
logging.info('Starting project...')
|