def websocket_handler(request):
channel = request.match_info.get('channel', 'postgresql2websocket')
ws = web.WebSocketResponse()
await ws.prepare(request)
request.app['websockets'].append(ws)
pool = request.app['pool']
async with pool.acquire() as connection:
queue = asyncio.Queue()
await connection.add_listener(channel, callback_websocket(ws))
try:
async for msg in ws:
pass
finally:
request.app['websockets'].remove(ws)
return ws
postgresql2websocket.py 文件源码
python
阅读 17
收藏 0
点赞 0
评论 0
评论列表
文章目录