m8chaa commited on
Commit
2da63f6
·
verified ·
1 Parent(s): 8ff087a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -17
app.py CHANGED
@@ -993,25 +993,10 @@ async def notifications(request: Request):
993
  raise HTTPException(status_code=500, detail=str(e))
994
 
995
 
996
- async def setup_listener():
997
- while True:
998
- try:
999
- db = AsyncClient()
1000
- users_ref = db.collection('users')
1001
- async for change in users_ref.on_snapshot():
1002
- # Handle changes
1003
- print(f"Change detected: {change}")
1004
- await asyncio.sleep(1) # Small delay to prevent tight loop
1005
- except Exception as e:
1006
- print(f"Listener disconnected: {e}")
1007
- await asyncio.sleep(5) # Wait before reconnecting
1008
 
1009
- @app.on_event("startup")
1010
- async def startup_event():
1011
- asyncio.create_task(setup_listener())
1012
 
1013
- # # Set up the Firebase listener
1014
- # users_watch = users_collection_ref.on_snapshot(on_snapshot)
1015
 
1016
  # # Set up the scheduler to update watch list every 24 hours
1017
  # scheduler = BackgroundScheduler()
 
993
  raise HTTPException(status_code=500, detail=str(e))
994
 
995
 
 
 
 
 
 
 
 
 
 
 
 
 
996
 
 
 
 
997
 
998
+ # Set up the Firebase listener
999
+ users_watch = users_collection_ref.on_snapshot(on_snapshot)
1000
 
1001
  # # Set up the scheduler to update watch list every 24 hours
1002
  # scheduler = BackgroundScheduler()