Omkar008 commited on
Commit
3360fd5
1 Parent(s): eeca6fc

Update test.py

Browse files
Files changed (1) hide show
  1. test.py +5 -3
test.py CHANGED
@@ -5,7 +5,7 @@ from jose import jwt
5
  import webbrowser
6
  import base64
7
  import logging
8
-
9
 
10
  app = FastAPI()
11
  oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
@@ -243,8 +243,9 @@ async def test_websocket(websocket: WebSocket):
243
  messages=get_messages(access_token)
244
  print(len(messages))
245
  await websocket.send_json({"total_messages": len(messages)})
 
246
  await websocket.send_json({"message":"Successfully sent all the Data !"})
247
-
248
 
249
  attachments = []
250
  prev_data=""
@@ -315,7 +316,8 @@ async def test_websocket(websocket: WebSocket):
315
  await websocket.send_json({"message":"Successfully sent all the Data !"})
316
 
317
  await event_generator(data)
318
- # await websocket.close()
 
319
 
320
  @app.get("/token")
321
  async def get_token(token: str = Depends(oauth2_scheme)):
 
5
  import webbrowser
6
  import base64
7
  import logging
8
+ import time
9
 
10
  app = FastAPI()
11
  oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
 
243
  messages=get_messages(access_token)
244
  print(len(messages))
245
  await websocket.send_json({"total_messages": len(messages)})
246
+ time.sleep(0.25)
247
  await websocket.send_json({"message":"Successfully sent all the Data !"})
248
+ time.sleep(0.25)
249
 
250
  attachments = []
251
  prev_data=""
 
316
  await websocket.send_json({"message":"Successfully sent all the Data !"})
317
 
318
  await event_generator(data)
319
+ logging.info("Closing connection")
320
+ await websocket.close()
321
 
322
  @app.get("/token")
323
  async def get_token(token: str = Depends(oauth2_scheme)):