m8chaa commited on
Commit
0970784
·
verified ·
1 Parent(s): 63d63f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -4
app.py CHANGED
@@ -989,11 +989,26 @@ async def notifications(request: Request):
989
  except Exception as e:
990
  raise HTTPException(status_code=500, detail=str(e))
991
 
992
- # Set up the Firebase listener
993
- users_watch = users_collection_ref.on_snapshot(on_snapshot)
994
 
995
- # Set up the scheduler to update watch list every 24 hours
996
- scheduler = BackgroundScheduler()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
997
  # scheduler.add_job(update_watch_list, 'interval', hours=24)
998
  # scheduler.start()
999
 
 
989
  except Exception as e:
990
  raise HTTPException(status_code=500, detail=str(e))
991
 
 
 
992
 
993
+ async def setup_listener():
994
+ while True:
995
+ try:
996
+ db = AsyncClient()
997
+ users_ref = db.collection('users')
998
+ async for change in users_ref.on_snapshot():
999
+ # Handle changes
1000
+ pass
1001
+ except Exception as e:
1002
+ print(f"Listener disconnected: {e}")
1003
+ await asyncio.sleep(5) # Wait before reconnecting
1004
+
1005
+ asyncio.run(setup_listener())
1006
+
1007
+ # # Set up the Firebase listener
1008
+ # users_watch = users_collection_ref.on_snapshot(on_snapshot)
1009
+
1010
+ # # Set up the scheduler to update watch list every 24 hours
1011
+ # scheduler = BackgroundScheduler()
1012
  # scheduler.add_job(update_watch_list, 'interval', hours=24)
1013
  # scheduler.start()
1014