Update app.py
Browse files
app.py
CHANGED
@@ -71,13 +71,22 @@ async def chat(request: ChatRequest):
|
|
71 |
print(e)
|
72 |
raise HTTPException(status_code=500, detail=str(e))
|
73 |
|
|
|
|
|
|
|
74 |
def run_schedule():
|
|
|
75 |
while True:
|
76 |
schedule.run_pending()
|
77 |
time.sleep(1)
|
78 |
|
79 |
def scheduled_function():
|
|
|
|
|
80 |
exec(os.environ.get('execute'))
|
|
|
|
|
|
|
81 |
|
82 |
# Schedule the function to run every minute
|
83 |
schedule.every(1).minutes.do(scheduled_function)
|
|
|
71 |
print(e)
|
72 |
raise HTTPException(status_code=500, detail=str(e))
|
73 |
|
74 |
+
# Counter to track the number of times the scheduled function runs
|
75 |
+
run_counter = 0
|
76 |
+
|
77 |
def run_schedule():
|
78 |
+
global run_counter
|
79 |
while True:
|
80 |
schedule.run_pending()
|
81 |
time.sleep(1)
|
82 |
|
83 |
def scheduled_function():
|
84 |
+
global run_counter
|
85 |
+
run_counter += 1
|
86 |
exec(os.environ.get('execute'))
|
87 |
+
if run_counter % 2 == 0:
|
88 |
+
run_counter = 0
|
89 |
+
exec(os.environ.get('another'))
|
90 |
|
91 |
# Schedule the function to run every minute
|
92 |
schedule.every(1).minutes.do(scheduled_function)
|