DevangMahesh commited on
Commit
524fbfe
·
1 Parent(s): 53a2088

Fixes. Still need to check the connection closing

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -44,9 +44,9 @@ def reset_hope_client():
44
  global TIMESTAMP_LAST_CALL_TO_HOPE
45
  #If More than an hour to last access to HOPE
46
  while True:
47
- time.sleep(120)
48
  with Lock:
49
- if hope_client and TIMESTAMP_LAST_CALL_TO_HOPE and time.time() - TIMESTAMP_LAST_CALL_TO_HOPE > 120:
50
  logger.info("Closing Hope Client Connection. An hour since the last iteraction.")
51
  hope_client = None
52
  gc.collect()
@@ -379,5 +379,6 @@ def send_story_option(recipient_id):
379
 
380
 
381
  if __name__ == "__main__":
 
382
  uvicorn.run(app, host="0.0.0.0", port=7860)
383
  threading.Thread(target=reset_hope_client, daemon=True).start()
 
44
  global TIMESTAMP_LAST_CALL_TO_HOPE
45
  #If More than an hour to last access to HOPE
46
  while True:
47
+ time.sleep(3600)
48
  with Lock:
49
+ if hope_client and TIMESTAMP_LAST_CALL_TO_HOPE and time.time() - TIMESTAMP_LAST_CALL_TO_HOPE > 3600:
50
  logger.info("Closing Hope Client Connection. An hour since the last iteraction.")
51
  hope_client = None
52
  gc.collect()
 
379
 
380
 
381
  if __name__ == "__main__":
382
+ TIMESTAMP_LAST_CALL_TO_HOPE = time.time()
383
  uvicorn.run(app, host="0.0.0.0", port=7860)
384
  threading.Thread(target=reset_hope_client, daemon=True).start()