Тест long polling
This commit is contained in:
parent
df3629138c
commit
22902048cd
1 changed files with 3 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
import websockets
|
import websockets
|
||||||
from fastapi import WebSocket, WebSocketDisconnect, Depends, HTTPException, status
|
from fastapi import WebSocket, WebSocketDisconnect, Depends, HTTPException, status
|
||||||
|
@ -158,8 +159,8 @@ async def chat_ws(
|
||||||
|
|
||||||
class PollingManager:
|
class PollingManager:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.waiters: dict[int, list[asyncio.Future]] = {}
|
self.waiters: dict[int, list[asyncio.Future]] = defaultdict(list)
|
||||||
self.messages: dict[int, list[dict]] = {}
|
self.messages: dict[int, list[dict]] = defaultdict(list)
|
||||||
|
|
||||||
async def poll(self, chat_id: int):
|
async def poll(self, chat_id: int):
|
||||||
future = asyncio.Future()
|
future = asyncio.Future()
|
||||||
|
|
Loading…
Add table
Reference in a new issue