{
  "id": "task_libraries:websocket/python",
  "path": "/exapedia/python-websocket-libraries",
  "template": {
    "id": "task_libraries",
    "version": 4
  },
  "title": "Python WebSocket libraries",
  "answer": [
    {
      "t": "text",
      "text": "Python WebSocket libraries open long-lived, two-way connections between a client and a server. A connection starts as an HTTP request and then carries messages in both directions until either side closes it. These libraries let chat apps, live dashboards, and AI agents stream data without polling."
    }
  ],
  "breadcrumb": [
    {
      "label": "Tools"
    },
    {
      "label": "Python WebSocket libraries"
    }
  ],
  "sections": [
    {
      "id": "libraries_popularity",
      "anchor": "popularity",
      "heading": "Popularity",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Monthly downloads",
            "Stars",
            "Last release",
            "License"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#starlette",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F127"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F128"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F136"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F131"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F129"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#aiohttp",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F145"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F146"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F154"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F149"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F147"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#websockets",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F163"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F164"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F170"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F167"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F165"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#websocket-client",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F178"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F179"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F185"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F182"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F180"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#tornado",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F193"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F194"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F202"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F197"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F195"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#wsproto",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F211"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F212"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F218"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F215"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F213"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#simple-websocket",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F227"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F228"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F236"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F231"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F229"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#trio-websocket",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F245"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F246"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F254"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F249"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F247"
                }
              ]
            ]
          ],
          "variant": "pop",
          "caption": [
            {
              "t": "text",
              "text": "Downloads: "
            },
            {
              "t": "text",
              "text": "PyPI"
            },
            {
              "t": "text",
              "text": ", last thirty days. Stars and releases: GitHub. Amber: no release in over a year."
            }
          ]
        }
      ],
      "note": [
        {
          "t": "link",
          "href": "#websockets",
          "label": [
            {
              "t": "text",
              "text": "websockets"
            }
          ]
        },
        {
          "t": "text",
          "text": " has the most monthly downloads among the dedicated WebSocket libraries in this comparison, at "
        },
        {
          "t": "fact",
          "fact": "F164"
        },
        {
          "t": "text",
          "text": "."
        }
      ]
    },
    {
      "id": "libraries_capabilities",
      "anchor": "capabilities",
      "heading": "Capabilities",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Client API",
            "Server API"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#starlette",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F127"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F137"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F138"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#aiohttp",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F145"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F155"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F156"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#websockets",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F163"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F171"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F172"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#websocket-client",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F178"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F186"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F187"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#tornado",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F193"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F203"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F204"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#wsproto",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F211"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F219"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F220"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#simple-websocket",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F227"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F237"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F238"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#trio-websocket",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F245"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F255"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F256"
                }
              ]
            ]
          ],
          "variant": "cap"
        }
      ]
    },
    {
      "id": "libraries_entries",
      "anchor": "libraries",
      "heading": "Libraries",
      "blocks": [
        {
          "b": "entry",
          "anchor": "starlette",
          "name": [
            {
              "t": "fact",
              "fact": "F127"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/Kludex/starlette"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/starlette"
            },
            {
              "label": "Docs",
              "href": "https://api.github.com/repos/encode/starlette/contents/docs/websockets.md"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F134"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F128"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F136"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F130"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F129"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/encode/starlette/contents/docs/websockets.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F127"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F143"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F144"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/fastapi/fastapi",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F143"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "@app.websocket(\"/ws/{client_id}\")\nasync def websocket_endpoint(websocket: WebSocket, client_id: int):\n    await manager.connect(websocket)\n    try:\n        while True:\n            data = await websocket.receive_text()\n            await manager.send_personal_message(f\"You wrote: {data}\", websocket)\n            await manager.broadcast(f\"Client #{client_id} says: {data}\")\n    except WebSocketDisconnect:\n        manager.disconnect(websocket)\n        await manager.broadcast(f\"Client #{client_id} left the chat\")\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/fastapi/fastapi/blob/05e6df7e906c3decba377c37548019973f40bf15/docs_src/websockets_/tutorial003.py#L71-L81",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F142"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=starlette%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F127"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from starlette.websockets import WebSocket\nasync def app(scope, receive, send):\n    websocket = WebSocket(scope=scope, receive=receive, send=send)\n    await websocket.accept()\n    await websocket.send_text('Hello, world!')\n    await websocket.close()\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/encode/starlette/contents/docs/websockets.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "websockets.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F132"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "aiohttp",
          "name": [
            {
              "t": "fact",
              "fact": "F145"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/aio-libs/aiohttp"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/aiohttp"
            },
            {
              "label": "Docs",
              "href": "https://docs.aiohttp.org/en/stable/client_reference.html"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F152"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F146"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F154"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F148"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F147"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://docs.aiohttp.org/en/stable/client_reference.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F145"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F161"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F162"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/Comfy-Org/ComfyUI",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F161"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "async def websocket_handler(request):\n    ws = web.WebSocketResponse()\n    await ws.prepare(request)\n    sid = request.rel_url.query.get('clientId', '')\n    if sid:\n        # Reusing existing session, remove old\n        self.sockets.pop(sid, None)\n    else:\n        sid = uuid.uuid4().hex\n\n    # Store WebSocket for backward compatibility\n    self.sockets[sid] = ws\n    # Store metadata separately\n    self.sockets_metadata[sid] = {\"feature_flags\": {}}\n\n    try:\n        # Send initial state to the new client\n        await self.send(\"status\", {\"status\": self.get_queue_info(), \"sid\": sid}, sid)\n        # On reconnect if we are the currently executing client send the current node\n        if self.client_id == sid and self.last_node_id is not None:\n            await self.send(\"executing\", { \"node\": self.last_node_id }, sid)\n\n        # Flag to track if we've received the first message\n        first_message = True\n\n        async for msg in ws:\n            if msg.type == aiohttp.WSMsgType.ERROR:\n                logging.warning('ws connection closed with exception %s' % ws.exception())\n            elif msg.type == aiohttp.WSMsgType.TEXT:\n                try:\n                    data = json.loads(msg.data)\n                    # Check if first message is feature flags\n                    if first_message and data.get(\"type\") == \"feature_flags\":\n                        # Store client feature flags\n                        client_flags = data.get(\"data\", {})\n                        self.sockets_metadata[sid][\"feature_flags\"] = client_flags\n\n                        # Send server feature flags in response\n                        await self.send(\n                            \"feature_flags\",\n                            feature_flags.get_server_features(),\n                            sid,\n                        )\n\n                        logging.debug(\n                            f\"Feature flags negotiated for client {sid}: {client_flags}\"\n                        )\n                    first_message = False\n                except json.JSONDecodeError:\n                    logging.warning(\n                        f\"Invalid JSON received from client {sid}: {msg.data}\"\n                    )\n                except Exception as e:\n                    logging.error(f\"Error processing WebSocket message: {e}\")\n    finally:\n        self.sockets.pop(sid, None)\n        self.sockets_metadata.pop(sid, None)\n    return ws\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/Comfy-Org/ComfyUI/blob/d5d59c4011312df6b3a4241fb48c045289ad9441/server.py#L337-L394",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F160"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=aiohttp%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F145"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import asyncio\nimport aiohttp\nasync def main():\n    async with aiohttp.ClientSession() as session:\n        async with session.ws_connect('ws://localhost:8765') as ws:\n            await ws.send_str('hello')\nasyncio.run(main())\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://docs.aiohttp.org/en/stable/client_quickstart.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "client_quickstart.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F150"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "websockets",
          "name": [
            {
              "t": "fact",
              "fact": "F163"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/python-websockets/websockets"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/websockets"
            },
            {
              "label": "Docs",
              "href": "https://api.github.com/repos/python-websockets/websockets/contents/README.rst"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F12"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F164"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F170"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F166"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F165"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/python-websockets/websockets/contents/README.rst",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F163"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F13"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F14"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F15"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F16"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F17"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F18"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F19"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F20"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F176"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F177"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/Kludex/uvicorn",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F176"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def send_keepalive_ping(self) -> None:\n    self.ping_timer = None\n    if self.close_sent or self.transport.is_closing():  # pragma: no cover\n        return\n    # Random 4-byte payload identifies this ping; `handle_pong` uses it to ignore stale or unsolicited pongs.\n    # See https://github.com/python-websockets/websockets/blob/4d229bf9f583d593aa103287aee0a77c9fbc3a79/src/websockets/asyncio/connection.py#L624\n    self.pending_ping_payload = struct.pack(\"!I\", random.getrandbits(32))\n    self.ping_sent_at = self.loop.time()\n    self.conn.send_ping(self.pending_ping_payload)\n    self.transport.write(b\"\".join(self.conn.data_to_send()))\n    if self.ping_timeout is not None:\n        self.pong_timer = self.loop.call_later(self.ping_timeout, self.keepalive_timeout)\n    else:  # pragma: no cover\n        self.schedule_ping()\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/Kludex/uvicorn/blob/a99c1b76ee9caea67ff98e2ccc457bd372db193f/uvicorn/protocols/websockets/websockets_sansio_impl.py#L343-L356",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F175"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20websockets%20for%20keepalive%20deadlines%2C%20handshake%20rejection%2C%20configured%20TLS%20connections%20and%20protocol%20transport%20integration&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F163"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import asyncio\nfrom websockets.asyncio.server import serve\nasync def echo(websocket):\n    async for message in websocket:\n        await websocket.send(message)\nasync def main():\n    server = await serve(echo, \"localhost\", 8765)\n    await server.serve_forever()\nasyncio.run(main())\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/python-websockets/websockets/blob/main/README.rst",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.rst"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F168"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "websocket-client",
          "name": [
            {
              "t": "fact",
              "fact": "F178"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/websocket-client/websocket-client"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/websocket-client"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/pypi/websocket-client/1.9.2/json"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F37"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F179"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F185"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F181"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F180"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/pypi/websocket-client/1.9.2/json",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F178"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F38"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F39"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F40"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F41"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F42"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F43"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F44"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F45"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F191"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F192"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/kubernetes-client/python",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F191"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def create_websocket(configuration, url, headers=None):\n    enableTrace(False)\n\n    # We just need to pass the Authorization, ignore all the other\n    # http headers we get from the generated code\n    header = []\n    if headers and 'authorization' in headers:\n            header.append(\"authorization: %s\" % headers['authorization'])\n    if headers and 'sec-websocket-protocol' in headers:\n        header.append(\"sec-websocket-protocol: %s\" %\n                      headers['sec-websocket-protocol'])\n    else:\n        header.append(\"sec-websocket-protocol: %s,%s\" % (V5_CHANNEL_PROTOCOL, V4_CHANNEL_PROTOCOL))\n\n    if url.startswith('wss://') and configuration.verify_ssl:\n        ssl_opts = {\n            'cert_reqs': ssl.CERT_REQUIRED,\n            'ca_certs': configuration.ssl_ca_cert or certifi.where(),\n        }\n        if configuration.assert_hostname is not None:\n            ssl_opts['check_hostname'] = configuration.assert_hostname\n    else:\n        ssl_opts = {'cert_reqs': ssl.CERT_NONE}\n\n    if configuration.cert_file:\n        ssl_opts['certfile'] = configuration.cert_file\n    if configuration.key_file:\n        ssl_opts['keyfile'] = configuration.key_file\n    if configuration.tls_server_name:\n        ssl_opts['server_hostname'] = configuration.tls_server_name\n\n    websocket = WebSocket(sslopt=ssl_opts, skip_utf8_validation=False)\n    connect_opt = {\n         'header': header\n    }\n\n    if configuration.proxy or configuration.proxy_headers:\n        connect_opt = websocket_proxycare(connect_opt, configuration, url, headers)\n\n    websocket.connect(url, **connect_opt)\n    return websocket\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/kubernetes-client/python/blob/a687381d746b91a6e0f49f7ec357320bcbf4cd38/kubernetes/stream/ws_client.py#L546-L586",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F190"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20websocket-client%20for%20keepalive%20deadlines%2C%20handshake%20rejection%2C%20configured%20TLS%20connections%20and%20protocol%20transport%20integration&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F178"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from websocket import create_connection\nws = create_connection(\"ws://echo.websocket.events/\")\nprint(ws.recv())\nprint(\"Sending 'Hello, World'...\")\nws.send(\"Hello, World\")\nprint(\"Sent\")\nprint(\"Receiving...\")\nresult =  ws.recv()\nprint(\"Received '%s'\" % result)\nws.close()\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/websocket-client/websocket-client/blob/master/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F183"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "tornado",
          "name": [
            {
              "t": "fact",
              "fact": "F193"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/tornadoweb/tornado"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/tornado"
            },
            {
              "label": "Docs",
              "href": "https://www.tornadoweb.org/en/stable/websocket.html"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F200"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F194"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F202"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F196"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F195"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://www.tornadoweb.org/en/stable/websocket.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F193"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F209"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F210"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/jupyter-server/jupyter_server",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F209"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def send_ping(self):\n    \"\"\"send a ping to keep the websocket alive\"\"\"\n    if self.ws_connection is None and self.ping_callback is not None:\n        self.ping_callback.stop()\n        return\n\n    if self.ws_connection.client_terminated:\n        self.close()\n        return\n\n    # check for timeout on pong.  Make sure that we really have sent a recent ping in\n    # case the machine with both server and client has been suspended since the last ping.\n    now = ioloop.IOLoop.current().time()\n    since_last_pong = 1e3 * (now - self.last_pong)\n    since_last_ping = 1e3 * (now - self.last_ping)\n    if since_last_ping < 2 * self.ping_interval and since_last_pong > self.ping_timeout:\n        self.log.warning(\"WebSocket ping timeout after %i ms.\", since_last_pong)\n        self.close()\n        return\n\n    self.ping(b\"\")\n    self.last_ping = now\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/jupyter-server/jupyter_server/blob/c4c5a51d2cf77d31a266376582ee05c4d661ad4b/jupyter_server/base/websocket.py#L161-L182",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F208"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=tornado%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F193"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import asyncio\nfrom tornado.websocket import websocket_connect\nasync def main():\n    connection = await websocket_connect('ws://localhost:8765')\n    await connection.write_message('hello')\n    connection.close()\nasyncio.run(main())\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://www.tornadoweb.org/en/stable/websocket.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "websocket.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F198"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "wsproto",
          "name": [
            {
              "t": "fact",
              "fact": "F211"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/python-hyper/wsproto"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/wsproto"
            },
            {
              "label": "Docs",
              "href": "https://api.github.com/repos/python-hyper/wsproto/contents/docs/source/basic-usage.rst"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F61"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F212"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F218"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F214"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F213"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/python-hyper/wsproto/contents/docs/source/basic-usage.rst",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F211"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F62"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F63"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F64"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F65"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F66"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F67"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F225"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F226"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/Kludex/uvicorn",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F225"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def send_500_response(self) -> None:\n    if self.response_started or self.handshake_complete:\n        return  # we cannot send responses anymore\n    headers: list[tuple[bytes, bytes]] = [\n        (b\"content-type\", b\"text/plain; charset=utf-8\"),\n        (b\"connection\", b\"close\"),\n        (b\"content-length\", b\"21\"),\n    ]\n    output = self.conn.send(wsproto.events.RejectConnection(status_code=500, headers=headers, has_body=True))\n    output += self.conn.send(wsproto.events.RejectData(data=b\"Internal Server Error\"))\n    self.transport.write(output)\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/Kludex/uvicorn/blob/a99c1b76ee9caea67ff98e2ccc457bd372db193f/uvicorn/protocols/websockets/wsproto_impl.py#L348-L358",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F224"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20wsproto%20for%20keepalive%20deadlines%2C%20handshake%20rejection%2C%20configured%20TLS%20connections%20and%20protocol%20transport%20integration&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F211"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from wsproto import WSConnection, ConnectionType\nfrom wsproto.events import Request\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/python-hyper/wsproto/contents/README.rst",
                  "label": [
                    {
                      "t": "text",
                      "text": "synchronous_client.py"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F216"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "simple-websocket",
          "name": [
            {
              "t": "fact",
              "fact": "F227"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/miguelgrinberg/simple-websocket"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/simple-websocket"
            },
            {
              "label": "Docs",
              "href": "https://simple-websocket.readthedocs.io/en/latest/api.html"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F234"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F228"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F236"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F230"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F229"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://simple-websocket.readthedocs.io/en/latest/api.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F227"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F243"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F244"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/miguelgrinberg/flask-sock",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F243"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "@wraps(f)\ndef websocket_route(*args, **kwargs):  # pragma: no cover\n    ws = Server(request.environ, **current_app.config.get(\n        'SOCK_SERVER_OPTIONS', {}))\n    try:\n        f(ws, *args, **kwargs)\n    except ConnectionClosed:\n        pass\n    try:\n        ws.close()\n    except:  # noqa: E722\n        pass\n\n    class WebSocketResponse(Response):\n        def __call__(self, *args, **kwargs):\n            if ws.mode == 'eventlet':\n                try:\n                    from eventlet.wsgi import WSGI_LOCAL\n                    ALREADY_HANDLED = []\n                except ImportError:\n                    from eventlet.wsgi import ALREADY_HANDLED\n                    WSGI_LOCAL = None\n\n                if hasattr(WSGI_LOCAL, 'already_handled'):\n                    WSGI_LOCAL.already_handled = True\n                return ALREADY_HANDLED\n            elif ws.mode == 'gunicorn':\n                raise StopIteration()\n            elif ws.mode == 'werkzeug':\n                return super().__call__(*args, **kwargs)\n            else:\n                return []\n\n    return WebSocketResponse()\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/miguelgrinberg/flask-sock/blob/bbc58f0d03b4d8e2793933a597200892c46c8ac1/src/flask_sock/__init__.py#L57-L90",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F242"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=simple-websocket%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F227"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from simple_websocket import Client\nws = Client.connect('ws://localhost:5000/echo')\nws.send('hello')\nws.close()\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://simple-websocket.readthedocs.io/en/latest/intro.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "intro.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F232"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "trio-websocket",
          "name": [
            {
              "t": "fact",
              "fact": "F245"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/python-trio/trio-websocket"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/trio-websocket"
            },
            {
              "label": "Docs",
              "href": "https://api.github.com/repos/python-trio/trio-websocket/contents/README.md"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F252"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F246"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F254"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F248"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F247"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/python-trio/trio-websocket/contents/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F245"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F261"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F262"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/SeleniumHQ/selenium",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F261"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "async def execute(self, cmd: Generator[dict, T, Any]) -> T:\n    \"\"\"Execute a command on the server and wait for the result.\n\n    Args:\n        cmd: any CDP command\n\n    Returns:\n        a CDP result\n    \"\"\"\n    cmd_id = next(self.id_iter)\n    cmd_event = trio.Event()\n    self.inflight_cmd[cmd_id] = cmd, cmd_event\n    request = next(cmd)\n    request[\"id\"] = cmd_id\n    if self.session_id:\n        request[\"sessionId\"] = self.session_id\n    request_str = json.dumps(request)\n    if logger.isEnabledFor(logging.DEBUG):\n        logger.debug(f\"Sending CDP message: {cmd_id} {cmd_event}: {request_str}\")\n    try:\n        await self.ws.send_message(request_str)\n    except WsConnectionClosed as wcc:\n        raise CdpConnectionClosed(wcc.reason) from None\n    await cmd_event.wait()\n    response = self.inflight_result.pop(cmd_id)\n    if logger.isEnabledFor(logging.DEBUG):\n        logger.debug(f\"Received CDP message: {response}\")\n    if isinstance(response, Exception):\n        if logger.isEnabledFor(logging.DEBUG):\n            logger.debug(f\"Exception raised by {cmd_event} message: {type(response).__name__}\")\n        raise response\n    return response\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/SeleniumHQ/selenium/blob/700f5ee1012c3105bedacaca65029749a4e5275a/py/private/cdp.py#L201-L232",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F260"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=trio-websocket%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F245"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import trio\nfrom sys import stderr\nfrom trio_websocket import open_websocket_url\nasync def main():\n    try:\n        async with open_websocket_url('wss://echo.websocket.org') as ws:\n            await ws.send_message('hello world!')\n            message = await ws.get_message()\n            print('Received message: %s' % message)\n    except OSError as ose:\n        print('Connection attempt failed: %s' % ose, file=stderr)\ntrio.run(main)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/python-trio/trio-websocket/contents/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F250"
            }
          ]
        }
      ]
    }
  ],
  "questions": [
    {
      "q": "Which Python WebSocket library should I use?",
      "a": [
        {
          "t": "link",
          "href": "#websockets",
          "label": [
            {
              "t": "text",
              "text": "websockets"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits servers and clients that use asyncio or threads. "
        },
        {
          "t": "link",
          "href": "#websocket-client",
          "label": [
            {
              "t": "text",
              "text": "websocket-client"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits callback-based client connections outside asyncio. "
        },
        {
          "t": "link",
          "href": "#wsproto",
          "label": [
            {
              "t": "text",
              "text": "wsproto"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits custom transports that own their network I/O."
        }
      ]
    },
    {
      "q": "How do I build a WebSocket server in Python?",
      "a": [
        {
          "t": "link",
          "href": "#websockets",
          "label": [
            {
              "t": "text",
              "text": "websockets"
            }
          ]
        },
        {
          "t": "text",
          "text": " builds WebSocket servers and clients with coroutine-based or threaded APIs. Only one coroutine at a time should receive messages from each connection."
        }
      ]
    },
    {
      "q": "Does websockets reconnect automatically?",
      "a": [
        {
          "t": "text",
          "text": "Its asynchronous connect iterator retries transient connection failures with exponential backoff."
        }
      ]
    },
    {
      "q": "What is websocket-client?",
      "a": [
        {
          "t": "link",
          "href": "#websocket-client",
          "label": [
            {
              "t": "text",
              "text": "websocket-client"
            }
          ]
        },
        {
          "t": "text",
          "text": " provides low-level WebSocket client APIs and callback-based long-lived connections. Applications built on asyncio need a native asyncio client instead."
        }
      ]
    }
  ],
  "facts": {
    "F1": {
      "label": "Library name, websockets",
      "display": "websockets",
      "asOf": "2026-11-17"
    },
    "F2": {
      "label": "Monthly downloads, websockets",
      "display": "518.1M",
      "asOf": "2026-11-16"
    },
    "F3": {
      "label": "License, websockets",
      "display": "BSD-3-Clause",
      "asOf": "2026-11-17"
    },
    "F4": {
      "label": "Package release, websockets",
      "display": "17.4, Oct 2026",
      "asOf": "2026-10-30"
    },
    "F5": {
      "label": "Package release date, websockets",
      "display": "Oct 2026",
      "asOf": "2026-10-30"
    },
    "F6": {
      "label": "Repository stars, websockets",
      "display": "5.7K",
      "asOf": "2026-11-17"
    },
    "F7": {
      "label": "Client support, websockets",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F8": {
      "label": "Server support, websockets",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F9": {
      "label": "Asyncio API, websockets",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F10": {
      "label": "Automatic reconnect, websockets",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F11": {
      "label": "Install, websockets",
      "display": "pip install websockets",
      "asOf": "2026-11-17"
    },
    "F12": {
      "label": "What it does, websockets",
      "display": "Builds WebSocket servers and clients in Python.",
      "asOf": "2026-11-17"
    },
    "F13": {
      "label": "strengths lead, websockets",
      "display": "Offers async and threaded interfaces",
      "asOf": "2026-11-17"
    },
    "F14": {
      "label": "strengths, websockets",
      "display": "Choose a coroutine-based or threaded connection API for the application.",
      "asOf": "2026-11-17"
    },
    "F15": {
      "label": "strengths lead, websockets",
      "display": "Retries transient connection failures",
      "asOf": "2026-11-17"
    },
    "F16": {
      "label": "strengths, websockets",
      "display": "Use the asynchronous connect iterator for reconnects with exponential backoff.",
      "asOf": "2026-11-17"
    },
    "F17": {
      "label": "limitations lead, websockets",
      "display": "Receives must stay serialized",
      "asOf": "2026-11-17"
    },
    "F18": {
      "label": "limitations, websockets",
      "display": "Have one coroutine receive messages from each connection at a time.",
      "asOf": "2026-11-17"
    },
    "F19": {
      "label": "limitations lead, websockets",
      "display": "Directly awaited connections need closing",
      "asOf": "2026-11-17"
    },
    "F20": {
      "label": "limitations, websockets",
      "display": "Close a directly awaited connection when the application finishes using it.",
      "asOf": "2026-11-17"
    },
    "F21": {
      "label": "Quickstart, websockets",
      "display": "#!/usr/bin/env python\n\nimport asyncio\nfrom websockets.asyncio.server import serve\n\nasync def echo(websocket):\n    async for message in websocket:\n        await websocket.send(message)\n\nasync def main():\n    server = await serve(echo, \"localhost\", 8765)\n    await server.serve_forever()\n\nasyncio.run(main())\n",
      "asOf": "2026-11-17"
    },
    "F22": {
      "label": "Project function, websockets",
      "display": "def send_keepalive_ping(self) -> None:\n    self.ping_timer = None\n    if self.close_sent or self.transport.is_closing():  # pragma: no cover\n        return\n    # Random 4-byte payload identifies this ping; `handle_pong` uses it to ignore stale or unsolicited pongs.\n    # See https://github.com/python-websockets/websockets/blob/4d229bf9f583d593aa103287aee0a77c9fbc3a79/src/websockets/asyncio/connection.py#L624\n    self.pending_ping_payload = struct.pack(\"!I\", random.getrandbits(32))\n    self.ping_sent_at = self.loop.time()\n    self.conn.send_ping(self.pending_ping_payload)\n    self.transport.write(b\"\".join(self.conn.data_to_send()))\n    if self.ping_timeout is not None:\n        self.pong_timer = self.loop.call_later(self.ping_timeout, self.keepalive_timeout)\n    else:  # pragma: no cover\n        self.schedule_ping()\n",
      "asOf": "2026-11-17"
    },
    "F23": {
      "label": "Project function reference, websockets",
      "display": "websockets_sansio_impl.py · send_keepalive_ping()",
      "asOf": "2026-11-17"
    },
    "F24": {
      "label": "Project repository, websockets",
      "display": "Kludex/uvicorn",
      "asOf": "2026-11-17"
    },
    "F25": {
      "label": "Project stars, Kludex/uvicorn",
      "display": "11.1K",
      "asOf": "2026-11-17"
    },
    "F26": {
      "label": "Project push date, Kludex/uvicorn",
      "display": "Nov 2026",
      "asOf": "2026-11-01"
    },
    "F27": {
      "label": "Library name, websocket-client",
      "display": "websocket-client",
      "asOf": "2026-11-17"
    },
    "F28": {
      "label": "Monthly downloads, websocket-client",
      "display": "179.6M",
      "asOf": "2026-11-16"
    },
    "F29": {
      "label": "License, websocket-client",
      "display": "Apache-2.0",
      "asOf": "2026-11-17"
    },
    "F30": {
      "label": "Package release, websocket-client",
      "display": "1.9.2, Aug 2026",
      "asOf": "2026-08-31"
    },
    "F31": {
      "label": "Package release date, websocket-client",
      "display": "Aug 2026",
      "asOf": "2026-08-31"
    },
    "F32": {
      "label": "Repository stars, websocket-client",
      "display": "3.7K",
      "asOf": "2026-11-17"
    },
    "F33": {
      "label": "Client support, websocket-client",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F34": {
      "label": "Asyncio API, websocket-client",
      "display": "Unsupported",
      "asOf": "2026-11-17"
    },
    "F35": {
      "label": "Automatic reconnect, websocket-client",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F36": {
      "label": "Install, websocket-client",
      "display": "pip install websocket-client",
      "asOf": "2026-11-17"
    },
    "F37": {
      "label": "What it does, websocket-client",
      "display": "Provides low-level WebSocket client APIs and callback-based long-lived connections.",
      "asOf": "2026-11-17"
    },
    "F38": {
      "label": "strengths lead, websocket-client",
      "display": "Handles long-lived callback connections",
      "asOf": "2026-11-17"
    },
    "F39": {
      "label": "strengths, websocket-client",
      "display": "Attach message, error, and close callbacks to WebSocketApp.",
      "asOf": "2026-11-17"
    },
    "F40": {
      "label": "strengths lead, websocket-client",
      "display": "Reconnects through its built-in dispatcher",
      "asOf": "2026-11-17"
    },
    "F41": {
      "label": "strengths, websocket-client",
      "display": "Set a reconnect delay on run_forever for automatic retries.",
      "asOf": "2026-11-17"
    },
    "F42": {
      "label": "limitations lead, websocket-client",
      "display": "Compression needs a different client",
      "asOf": "2026-11-17"
    },
    "F43": {
      "label": "limitations, websocket-client",
      "display": "Choose another client when the peer requires permessage-deflate.",
      "asOf": "2026-11-17"
    },
    "F44": {
      "label": "limitations lead, websocket-client",
      "display": "Asyncio needs another integration",
      "asOf": "2026-11-17"
    },
    "F45": {
      "label": "limitations, websocket-client",
      "display": "Choose a native asyncio client for coroutine-based applications.",
      "asOf": "2026-11-17"
    },
    "F46": {
      "label": "Quickstart, websocket-client",
      "display": "from websocket import create_connection\n\nws = create_connection(\"ws://echo.websocket.events/\")\nprint(ws.recv())\nprint(\"Sending 'Hello, World'...\")\nws.send(\"Hello, World\")\nprint(\"Sent\")\nprint(\"Receiving...\")\nresult =  ws.recv()\nprint(\"Received '%s'\" % result)\nws.close()\n",
      "asOf": "2026-11-17"
    },
    "F47": {
      "label": "Project function, websocket-client",
      "display": "def create_websocket(configuration, url, headers=None):\n    enableTrace(False)\n\n    # We just need to pass the Authorization, ignore all the other\n    # http headers we get from the generated code\n    header = []\n    if headers and 'authorization' in headers:\n            header.append(\"authorization: %s\" % headers['authorization'])\n    if headers and 'sec-websocket-protocol' in headers:\n        header.append(\"sec-websocket-protocol: %s\" %\n                      headers['sec-websocket-protocol'])\n    else:\n        header.append(\"sec-websocket-protocol: %s,%s\" % (V5_CHANNEL_PROTOCOL, V4_CHANNEL_PROTOCOL))\n\n    if url.startswith('wss://') and configuration.verify_ssl:\n        ssl_opts = {\n            'cert_reqs': ssl.CERT_REQUIRED,\n            'ca_certs': configuration.ssl_ca_cert or certifi.where(),\n        }\n        if configuration.assert_hostname is not None:\n            ssl_opts['check_hostname'] = configuration.assert_hostname\n    else:\n        ssl_opts = {'cert_reqs': ssl.CERT_NONE}\n\n    if configuration.cert_file:\n        ssl_opts['certfile'] = configuration.cert_file\n    if configuration.key_file:\n        ssl_opts['keyfile'] = configuration.key_file\n    if configuration.tls_server_name:\n        ssl_opts['server_hostname'] = configuration.tls_server_name\n\n    websocket = WebSocket(sslopt=ssl_opts, skip_utf8_validation=False)\n    connect_opt = {\n         'header': header\n    }\n\n    if configuration.proxy or configuration.proxy_headers:\n        connect_opt = websocket_proxycare(connect_opt, configuration, url, headers)\n\n    websocket.connect(url, **connect_opt)\n    return websocket\n",
      "asOf": "2026-11-17"
    },
    "F48": {
      "label": "Project function reference, websocket-client",
      "display": "ws_client.py · create_websocket()",
      "asOf": "2026-11-17"
    },
    "F49": {
      "label": "Project repository, websocket-client",
      "display": "kubernetes-client/python",
      "asOf": "2026-11-17"
    },
    "F50": {
      "label": "Project stars, kubernetes-client/python",
      "display": "7.7K",
      "asOf": "2026-11-17"
    },
    "F51": {
      "label": "Project push date, kubernetes-client/python",
      "display": "Nov 2026",
      "asOf": "2026-11-10"
    },
    "F52": {
      "label": "Library name, wsproto",
      "display": "wsproto",
      "asOf": "2026-11-17"
    },
    "F53": {
      "label": "Monthly downloads, wsproto",
      "display": "71.7M",
      "asOf": "2026-11-16"
    },
    "F54": {
      "label": "License, wsproto",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F55": {
      "label": "Package release, wsproto",
      "display": "1.3.2, Nov 2025",
      "asOf": "2025-11-20"
    },
    "F56": {
      "label": "Package release date, wsproto",
      "display": "Nov 2025",
      "asOf": "2025-11-20"
    },
    "F57": {
      "label": "Repository stars, wsproto",
      "display": "303",
      "asOf": "2026-11-17"
    },
    "F58": {
      "label": "Client support, wsproto",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F59": {
      "label": "Server support, wsproto",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F60": {
      "label": "Install, wsproto",
      "display": "pip install wsproto",
      "asOf": "2026-11-17"
    },
    "F61": {
      "label": "What it does, wsproto",
      "display": "Implements WebSocket protocol state and frame handling without owning network I/O.",
      "asOf": "2026-11-17"
    },
    "F62": {
      "label": "strengths lead, wsproto",
      "display": "Fits custom network transports",
      "asOf": "2026-11-17"
    },
    "F63": {
      "label": "strengths, wsproto",
      "display": "Embed the protocol state machine in the application’s own transport.",
      "asOf": "2026-11-17"
    },
    "F64": {
      "label": "strengths lead, wsproto",
      "display": "Supports client and server roles",
      "asOf": "2026-11-17"
    },
    "F65": {
      "label": "strengths, wsproto",
      "display": "Use the same protocol class for either end of a WebSocket connection.",
      "asOf": "2026-11-17"
    },
    "F66": {
      "label": "limitations lead, wsproto",
      "display": "Network I/O stays application-owned",
      "asOf": "2026-11-17"
    },
    "F67": {
      "label": "limitations, wsproto",
      "display": "Provide the code that reads and writes bytes on the actual connection.",
      "asOf": "2026-11-17"
    },
    "F68": {
      "label": "Quickstart, wsproto",
      "display": "\"\"\"\nThe client reads a line from stdin, sends it to the server, then prints the\nresponse. This is a poor implementation of a client. It is only intended to\ndemonstrate how to use wsproto.\n\"\"\"\nfrom __future__ import annotations\n\nimport socket\nimport sys\n\nfrom wsproto import WSConnection\nfrom wsproto.connection import ConnectionType\nfrom wsproto.events import (\n    AcceptConnection,\n    CloseConnection,\n    Message,\n    Ping,\n    Pong,\n    Request,\n    TextMessage,\n)\n\nRECEIVE_BYTES = 4096\n\n\ndef main() -> None:\n    \"\"\"Run the client.\"\"\"\n    try:\n        host = sys.argv[1]\n        port = int(sys.argv[2])\n    except (IndexError, ValueError):\n        print(f\"Usage: {sys.argv[0]} <HOST> <PORT>\")\n        sys.exit(1)\n\n    try:\n        wsproto_demo(host, port)\n    except KeyboardInterrupt:\n        print(\"\\nReceived SIGINT: shutting down…\")\n\n\ndef wsproto_demo(host: str, port: int) -> None:\n    \"\"\"\n    Demonstrate wsproto:\n\n    0) Open TCP connection\n    1) Negotiate WebSocket opening handshake\n    2) Send a message and display response\n    3) Send ping and display pong\n    4) Negotiate WebSocket closing handshake\n    \"\"\"\n    # 0) Open TCP connection\n    print(f\"Connecting to {host}:{port}\")\n    conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n    conn.connect((host, port))\n\n    # 1) Negotiate WebSocket opening handshake\n    print(\"Opening WebSocket\")\n    ws = WSConnection(ConnectionType.CLIENT)\n    # Because this is a client WebSocket, we need to initiate the connection\n    # handshake by sending a Request event.\n    net_send(ws.send(Request(host=host, target=\"server\")), conn)\n    net_recv(ws, conn)\n    handle_events(ws)\n\n    # 2) Send a message and display response\n    message = \"wsproto is great\"\n    print(f\"Sending message: {message}\")\n    net_send(ws.send(Message(data=message)), conn)\n    net_recv(ws, conn)\n    handle_events(ws)\n\n    # 3) Send ping and display pong\n    payload = b\"table tennis\"\n    print(f\"Sending ping: {payload!r}\")\n    net_send(ws.send(Ping(payload=payload)), conn)\n    net_recv(ws, conn)\n    handle_events(ws)\n\n    # 4) Negotiate WebSocket closing handshake\n    print(\"Closing WebSocket\")\n    net_send(ws.send(CloseConnection(code=1000, reason=\"sample reason\")), conn)\n    # After sending the closing frame, we won't get any more events. The server\n    # should send a reply and then close the connection, so we need to receive\n    # twice:\n    net_recv(ws, conn)\n    conn.shutdown(socket.SHUT_WR)\n    net_recv(ws, conn)\n\n\ndef net_send(out_data: bytes, conn: socket.socket) -> None:\n    \"\"\"Write pending data from websocket to network.\"\"\"\n    print(f\"Sending {len(out_data)} bytes\")\n    conn.send(out_data)\n\n\ndef net_recv(ws: WSConnection, conn: socket.socket) -> None:\n    \"\"\"Read pending data from network into websocket.\"\"\"\n    in_data = conn.recv(RECEIVE_BYTES)\n    if not in_data:\n        # A receive of zero bytes indicates the TCP socket has been closed. We\n        # need to pass None to wsproto to update its internal state.\n        print(\"Received 0 bytes (connection closed)\")\n        ws.receive_data(None)\n    else:\n        print(f\"Received {len(in_data)} bytes\")\n        ws.receive_data(in_data)\n\n\ndef handle_events(ws: WSConnection) -> None:\n    for event in ws.events():\n        if isinstance(event, AcceptConnection):\n            print(\"WebSocket negotiation complete\")\n        elif isinstance(event, TextMessage):\n            print(f\"Received message: {event.data}\")\n        elif isinstance(event, Pong):\n            print(f\"Received pong: {event.payload!r}\")\n        else:\n            raise Exception(\"Do not know how to handle event: \" + str(event))\n\n\nif __name__ == \"__main__\":\n    main()\n",
      "asOf": "2026-11-17"
    },
    "F69": {
      "label": "Project function, wsproto",
      "display": "def data_received(self, data: bytes) -> None:\n    try:\n        self.conn.receive_data(data)\n    except RemoteProtocolError as err:\n        # TODO: Remove `type: ignore` when wsproto fixes the type annotation.\n        self.transport.write(self.conn.send(err.event_hint))  # type: ignore[arg-type]  # noqa: E501\n        self.transport.close()\n    except LocalProtocolError:\n        # Data received after the close handshake completed, e.g. a pong the client\n        # sent while the server's close was in flight.\n        self.transport.close()\n    else:\n        self.handle_events()\n",
      "asOf": "2026-11-17"
    },
    "F70": {
      "label": "Project function reference, wsproto",
      "display": "wsproto_impl.py · data_received()",
      "asOf": "2026-11-17"
    },
    "F71": {
      "label": "Project repository, wsproto",
      "display": "Kludex/uvicorn",
      "asOf": "2026-11-17"
    },
    "F72": {
      "label": "Project stars, Kludex/uvicorn",
      "display": "11.1K",
      "asOf": "2026-11-17"
    },
    "F73": {
      "label": "Project push date, Kludex/uvicorn",
      "display": "Nov 2026",
      "asOf": "2026-11-01"
    },
    "F74": {
      "label": "Library name, python-socketio",
      "display": "python-socketio",
      "asOf": "2026-11-17"
    },
    "F75": {
      "label": "Monthly downloads, python-socketio",
      "display": "26.8M",
      "asOf": "2026-11-16"
    },
    "F76": {
      "label": "License, python-socketio",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F77": {
      "label": "Package release, python-socketio",
      "display": "5.18.1, Nov 2026",
      "asOf": "2026-11-03"
    },
    "F78": {
      "label": "Package release date, python-socketio",
      "display": "Nov 2026",
      "asOf": "2026-11-03"
    },
    "F79": {
      "label": "Repository stars, python-socketio",
      "display": "4.4K",
      "asOf": "2026-11-17"
    },
    "F80": {
      "label": "Client support, python-socketio",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F81": {
      "label": "Server support, python-socketio",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F82": {
      "label": "Asyncio API, python-socketio",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F83": {
      "label": "Automatic reconnect, python-socketio",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F84": {
      "label": "Install, python-socketio",
      "display": "pip install \"python-socketio[asyncio_client]\"",
      "asOf": "2026-11-17"
    },
    "F85": {
      "label": "What it does, python-socketio",
      "display": "Implements Socket.IO event clients and servers with synchronous and asyncio variants.",
      "asOf": "2026-11-17"
    },
    "F86": {
      "label": "strengths lead, python-socketio",
      "display": "Provides event-based client communication",
      "asOf": "2026-11-17"
    },
    "F87": {
      "label": "strengths, python-socketio",
      "display": "Register named event handlers instead of handling each raw WebSocket frame.",
      "asOf": "2026-11-17"
    },
    "F88": {
      "label": "strengths lead, python-socketio",
      "display": "Offers synchronous and async variants",
      "asOf": "2026-11-17"
    },
    "F89": {
      "label": "strengths, python-socketio",
      "display": "Use standard or asyncio implementations of the Socket.IO client and server.",
      "asOf": "2026-11-17"
    },
    "F90": {
      "label": "limitations lead, python-socketio",
      "display": "Peers need compatible protocols",
      "asOf": "2026-11-17"
    },
    "F91": {
      "label": "limitations, python-socketio",
      "display": "Match the Socket.IO and Engine.IO protocol versions used by the peer.",
      "asOf": "2026-11-17"
    },
    "F92": {
      "label": "limitations lead, python-socketio",
      "display": "Multiple Gunicorn workers need coordination",
      "asOf": "2026-11-17"
    },
    "F93": {
      "label": "limitations, python-socketio",
      "display": "Use WebSocket transport and a message queue for multiple Gunicorn workers.",
      "asOf": "2026-11-17"
    },
    "F94": {
      "label": "Quickstart, python-socketio",
      "display": "import asyncio\nimport socketio\n\nsio = socketio.AsyncClient()\n\n@sio.event\nasync def connect():\n    print('connection established')\n\n@sio.event\nasync def my_message(data):\n    print('message received with ', data)\n    await sio.emit('my response', {'response': 'my response'})\n\n@sio.event\nasync def disconnect():\n    print('disconnected from server')\n\nasync def main():\n    await sio.connect('http://localhost:5000')\n    await sio.wait()\n\nif __name__ == '__main__':\n    asyncio.run(main())\n\n",
      "asOf": "2026-11-17"
    },
    "F95": {
      "label": "Developer need",
      "display": "Async or threaded WebSocket connections",
      "asOf": "2026-11-17"
    },
    "F96": {
      "label": "Why choose websockets",
      "display": "multiple documented network I/O interfaces",
      "asOf": "2026-11-17"
    },
    "F97": {
      "label": "Developer need in introduction",
      "display": "async or threaded WebSocket connections",
      "asOf": "2026-11-17"
    },
    "F98": {
      "label": "When to consider wsproto",
      "display": "the application owns the network transport",
      "asOf": "2026-11-17"
    },
    "F99": {
      "label": "Developer need",
      "display": "Callback-based client connections",
      "asOf": "2026-11-17"
    },
    "F100": {
      "label": "Why choose websocket-client",
      "display": "long-lived connection callbacks",
      "asOf": "2026-11-17"
    },
    "F101": {
      "label": "Developer need in introduction",
      "display": "callback-based client connections",
      "asOf": "2026-11-17"
    },
    "F102": {
      "label": "When to consider websockets",
      "display": "the application needs a native asyncio interface",
      "asOf": "2026-11-17"
    },
    "F103": {
      "label": "Developer need",
      "display": "Named Socket.IO application events",
      "asOf": "2026-11-17"
    },
    "F104": {
      "label": "Why choose python-socketio",
      "display": "event-based client and server communication",
      "asOf": "2026-11-17"
    },
    "F105": {
      "label": "Developer need in introduction",
      "display": "named Socket.IO application events",
      "asOf": "2026-11-17"
    },
    "F106": {
      "label": "When to consider websockets",
      "display": "the peer uses an ordinary WebSocket message API",
      "asOf": "2026-11-17"
    },
    "F107": {
      "label": "Developer need",
      "display": "A custom WebSocket transport",
      "asOf": "2026-11-17"
    },
    "F108": {
      "label": "Why choose wsproto",
      "display": "an embeddable protocol state machine",
      "asOf": "2026-11-17"
    },
    "F109": {
      "label": "Developer need in introduction",
      "display": "a custom WebSocket transport",
      "asOf": "2026-11-17"
    },
    "F110": {
      "label": "Page introduction",
      "display": "Python WebSocket libraries let application developers exchange messages over WebSocket connections.",
      "asOf": "2026-11-17"
    },
    "F111": {
      "label": "FAQ: What is the best Python WebSocket library?",
      "display": "websockets offers async, threaded and Sans-I/O interfaces for clients and servers.",
      "asOf": "2026-11-17"
    },
    "F112": {
      "label": "FAQ: What is the best Python WebSocket library?",
      "display": "websocket-client provides client-side WebSocket APIs.",
      "asOf": "2026-11-17"
    },
    "F113": {
      "label": "FAQ: What is the best Python WebSocket library?",
      "display": "python-socketio implements the Socket.IO client and server protocol.",
      "asOf": "2026-11-17"
    },
    "F114": {
      "label": "FAQ: What is the best Python WebSocket library?",
      "display": "wsproto is a protocol layer that leaves network I/O to the application.",
      "asOf": "2026-11-17"
    },
    "F115": {
      "label": "FAQ: Should I use Socket.IO or an ordinary WebSocket API?",
      "display": "Socket.IO provides named event communication and supports HTTP long-polling and WebSocket transports.",
      "asOf": "2026-11-17"
    },
    "F116": {
      "label": "FAQ: Should I use Socket.IO or an ordinary WebSocket API?",
      "display": "Its client and server must use compatible Socket.IO protocol versions.",
      "asOf": "2026-11-17"
    },
    "F117": {
      "label": "FAQ: Which Python WebSocket client supports asyncio?",
      "display": "websockets provides a coroutine-based asyncio API.",
      "asOf": "2026-11-17"
    },
    "F118": {
      "label": "FAQ: Which Python WebSocket client supports asyncio?",
      "display": "python-socketio provides an asyncio implementation for its event protocol.",
      "asOf": "2026-11-17"
    },
    "F119": {
      "label": "FAQ: Which Python WebSocket client supports asyncio?",
      "display": "websocket-client is not compatible with asyncio as a native client API.",
      "asOf": "2026-11-17"
    },
    "F120": {
      "label": "FAQ: Can a Python WebSocket client reconnect automatically?",
      "display": "websockets connect can act as an asynchronous iterator that reconnects on transient failures with exponential backoff.",
      "asOf": "2026-11-17"
    },
    "F121": {
      "label": "FAQ: Can a Python WebSocket client reconnect automatically?",
      "display": "websocket-client run_forever reconnects when supplied a nonzero reconnect delay.",
      "asOf": "2026-11-17"
    },
    "F122": {
      "label": "FAQ: Can a Python WebSocket client reconnect automatically?",
      "display": "The Socket.IO client automatically reconnects after a dropped connection.",
      "asOf": "2026-11-17"
    },
    "F123": {
      "label": "FAQ: Why do concurrent receives raise an error?",
      "display": "websockets raises ConcurrencyError when coroutines receive concurrently on the same connection.",
      "asOf": "2026-11-17"
    },
    "F124": {
      "label": "FAQ: Does wsproto open the network connection for me?",
      "display": "wsproto does not perform network I/O; the application must connect its protocol bytes to a real transport.",
      "asOf": "2026-11-17"
    },
    "F125": {
      "label": "FAQ: Does websocket-client support permessage-deflate compression?",
      "display": "websocket-client explicitly excludes the permessage-deflate extension.",
      "asOf": "2026-11-17"
    },
    "F126": {
      "label": "FAQ: Can I run Socket.IO with multiple Gunicorn workers?",
      "display": "Use direct WebSocket connections and a shared message queue for that multi-worker setup; Gunicorn load balancing is incompatible with the long-polling transport.",
      "asOf": "2026-11-17"
    },
    "F127": {
      "label": "Library name, starlette",
      "display": "Starlette",
      "asOf": "2026-11-20"
    },
    "F128": {
      "label": "Monthly downloads, starlette",
      "display": "706.4M",
      "asOf": "2026-11-20"
    },
    "F129": {
      "label": "License, starlette",
      "display": "BSD-3-Clause",
      "asOf": "2026-11-20"
    },
    "F130": {
      "label": "Package release, starlette",
      "display": "1.10.0",
      "asOf": "2026-11-20"
    },
    "F131": {
      "label": "Package release date, starlette",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F132": {
      "label": "Install, starlette",
      "display": "python3 -m pip install starlette",
      "asOf": "2026-11-20"
    },
    "F133": {
      "label": "Quickstart, starlette",
      "display": "from starlette.websockets import WebSocket\nasync def app(scope, receive, send):\n    websocket = WebSocket(scope=scope, receive=receive, send=send)\n    await websocket.accept()\n    await websocket.send_text('Hello, world!')\n    await websocket.close()\n",
      "asOf": "2026-11-20"
    },
    "F134": {
      "label": "Official description, starlette",
      "display": "Provides a small ASGI library.",
      "asOf": "2026-11-20"
    },
    "F135": {
      "label": "Quickstart source file, starlette",
      "display": "docs/websockets.md",
      "asOf": "2026-11-20"
    },
    "F136": {
      "label": "Repository stars, starlette",
      "display": "12.7K",
      "asOf": "2026-11-20"
    },
    "F137": {
      "label": "Client API, starlette",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F138": {
      "label": "Server API, starlette",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F139": {
      "label": "Networking and concurrency role, starlette",
      "display": "ASGI WebSocket application object and routing integration; relies on a separate ASGI protocol server, not an external network client.",
      "asOf": "2026-11-20"
    },
    "F140": {
      "label": "Download scope, starlette",
      "display": "Full framework distribution; WebSocket-specific users and overlap with dependencies cannot be inferred.",
      "asOf": "2026-11-20"
    },
    "F141": {
      "label": "Project function, starlette",
      "display": "@app.websocket(\"/ws/{client_id}\")\nasync def websocket_endpoint(websocket: WebSocket, client_id: int):\n    await manager.connect(websocket)\n    try:\n        while True:\n            data = await websocket.receive_text()\n            await manager.send_personal_message(f\"You wrote: {data}\", websocket)\n            await manager.broadcast(f\"Client #{client_id} says: {data}\")\n    except WebSocketDisconnect:\n        manager.disconnect(websocket)\n        await manager.broadcast(f\"Client #{client_id} left the chat\")\n",
      "asOf": "2026-11-20"
    },
    "F142": {
      "label": "Project source file, starlette",
      "display": "docs_src/websockets_/tutorial003.py",
      "asOf": "2026-11-20"
    },
    "F143": {
      "label": "Project full_name, starlette",
      "display": "fastapi/fastapi",
      "asOf": "2026-11-20"
    },
    "F144": {
      "label": "Project stargazers_count, starlette",
      "display": "104.9K",
      "asOf": "2026-11-20"
    },
    "F145": {
      "label": "Library name, aiohttp",
      "display": "aiohttp",
      "asOf": "2026-11-20"
    },
    "F146": {
      "label": "Monthly downloads, aiohttp",
      "display": "562.2M",
      "asOf": "2026-11-20"
    },
    "F147": {
      "label": "License, aiohttp",
      "display": "Apache-2.0 AND MIT",
      "asOf": "2026-11-20"
    },
    "F148": {
      "label": "Package release, aiohttp",
      "display": "3.14.5",
      "asOf": "2026-11-20"
    },
    "F149": {
      "label": "Package release date, aiohttp",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F150": {
      "label": "Install, aiohttp",
      "display": "python3 -m pip install aiohttp",
      "asOf": "2026-11-20"
    },
    "F151": {
      "label": "Quickstart, aiohttp",
      "display": "import asyncio\nimport aiohttp\nasync def main():\n    async with aiohttp.ClientSession() as session:\n        async with session.ws_connect('ws://localhost:8765') as ws:\n            await ws.send_str('hello')\nasyncio.run(main())\n",
      "asOf": "2026-11-20"
    },
    "F152": {
      "label": "Official description, aiohttp",
      "display": "Provides an asyncio HTTP client and server framework.",
      "asOf": "2026-11-20"
    },
    "F153": {
      "label": "Quickstart source file, aiohttp",
      "display": "client_quickstart.html",
      "asOf": "2026-11-20"
    },
    "F154": {
      "label": "Repository stars, aiohttp",
      "display": "16.6K",
      "asOf": "2026-11-20"
    },
    "F155": {
      "label": "Client API, aiohttp",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F156": {
      "label": "Server API, aiohttp",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F157": {
      "label": "Networking and concurrency role, aiohttp",
      "display": "Asyncio HTTP client/server framework with native WebSocket client sessions and server responses; its distribution count includes all HTTP uses.",
      "asOf": "2026-11-20"
    },
    "F158": {
      "label": "Download scope, aiohttp",
      "display": "Full framework distribution; WebSocket-specific users and overlap with dependencies cannot be inferred.",
      "asOf": "2026-11-20"
    },
    "F159": {
      "label": "Project function, aiohttp",
      "display": "async def websocket_handler(request):\n    ws = web.WebSocketResponse()\n    await ws.prepare(request)\n    sid = request.rel_url.query.get('clientId', '')\n    if sid:\n        # Reusing existing session, remove old\n        self.sockets.pop(sid, None)\n    else:\n        sid = uuid.uuid4().hex\n\n    # Store WebSocket for backward compatibility\n    self.sockets[sid] = ws\n    # Store metadata separately\n    self.sockets_metadata[sid] = {\"feature_flags\": {}}\n\n    try:\n        # Send initial state to the new client\n        await self.send(\"status\", {\"status\": self.get_queue_info(), \"sid\": sid}, sid)\n        # On reconnect if we are the currently executing client send the current node\n        if self.client_id == sid and self.last_node_id is not None:\n            await self.send(\"executing\", { \"node\": self.last_node_id }, sid)\n\n        # Flag to track if we've received the first message\n        first_message = True\n\n        async for msg in ws:\n            if msg.type == aiohttp.WSMsgType.ERROR:\n                logging.warning('ws connection closed with exception %s' % ws.exception())\n            elif msg.type == aiohttp.WSMsgType.TEXT:\n                try:\n                    data = json.loads(msg.data)\n                    # Check if first message is feature flags\n                    if first_message and data.get(\"type\") == \"feature_flags\":\n                        # Store client feature flags\n                        client_flags = data.get(\"data\", {})\n                        self.sockets_metadata[sid][\"feature_flags\"] = client_flags\n\n                        # Send server feature flags in response\n                        await self.send(\n                            \"feature_flags\",\n                            feature_flags.get_server_features(),\n                            sid,\n                        )\n\n                        logging.debug(\n                            f\"Feature flags negotiated for client {sid}: {client_flags}\"\n                        )\n                    first_message = False\n                except json.JSONDecodeError:\n                    logging.warning(\n                        f\"Invalid JSON received from client {sid}: {msg.data}\"\n                    )\n                except Exception as e:\n                    logging.error(f\"Error processing WebSocket message: {e}\")\n    finally:\n        self.sockets.pop(sid, None)\n        self.sockets_metadata.pop(sid, None)\n    return ws\n",
      "asOf": "2026-11-20"
    },
    "F160": {
      "label": "Project source file, aiohttp",
      "display": "server.py",
      "asOf": "2026-11-20"
    },
    "F161": {
      "label": "Project full_name, aiohttp",
      "display": "Comfy-Org/ComfyUI",
      "asOf": "2026-11-20"
    },
    "F162": {
      "label": "Project stargazers_count, aiohttp",
      "display": "147.6K",
      "asOf": "2026-11-20"
    },
    "F163": {
      "label": "Library name, websockets",
      "display": "websockets",
      "asOf": "2026-11-20"
    },
    "F164": {
      "label": "Monthly downloads, websockets",
      "display": "539.1M",
      "asOf": "2026-11-20"
    },
    "F165": {
      "label": "License, websockets",
      "display": "BSD-3-Clause",
      "asOf": "2026-11-20"
    },
    "F166": {
      "label": "Package release, websockets",
      "display": "17.4",
      "asOf": "2026-11-20"
    },
    "F167": {
      "label": "Package release date, websockets",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F168": {
      "label": "Install, websockets",
      "display": "python3 -m pip install websockets",
      "asOf": "2026-11-20"
    },
    "F169": {
      "label": "Quickstart, websockets",
      "display": "import asyncio\nfrom websockets.asyncio.server import serve\nasync def echo(websocket):\n    async for message in websocket:\n        await websocket.send(message)\nasync def main():\n    server = await serve(echo, \"localhost\", 8765)\n    await server.serve_forever()\nasyncio.run(main())\n",
      "asOf": "2026-11-20"
    },
    "F170": {
      "label": "Repository stars, websockets",
      "display": "5.7K",
      "asOf": "2026-11-20"
    },
    "F171": {
      "label": "Client API, websockets",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F172": {
      "label": "Server API, websockets",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F173": {
      "label": "Networking and concurrency role, websockets",
      "display": "Dedicated WebSocket implementation with asyncio, synchronous threading, and Sans-I/O interfaces; selected example uses the protocol layer.",
      "asOf": "2026-11-20"
    },
    "F174": {
      "label": "Project function, websockets",
      "display": "def send_keepalive_ping(self) -> None:\n    self.ping_timer = None\n    if self.close_sent or self.transport.is_closing():  # pragma: no cover\n        return\n    # Random 4-byte payload identifies this ping; `handle_pong` uses it to ignore stale or unsolicited pongs.\n    # See https://github.com/python-websockets/websockets/blob/4d229bf9f583d593aa103287aee0a77c9fbc3a79/src/websockets/asyncio/connection.py#L624\n    self.pending_ping_payload = struct.pack(\"!I\", random.getrandbits(32))\n    self.ping_sent_at = self.loop.time()\n    self.conn.send_ping(self.pending_ping_payload)\n    self.transport.write(b\"\".join(self.conn.data_to_send()))\n    if self.ping_timeout is not None:\n        self.pong_timer = self.loop.call_later(self.ping_timeout, self.keepalive_timeout)\n    else:  # pragma: no cover\n        self.schedule_ping()\n",
      "asOf": "2026-11-20"
    },
    "F175": {
      "label": "Project source file, websockets",
      "display": "uvicorn/protocols/websockets/websockets_sansio_impl.py",
      "asOf": "2026-11-20"
    },
    "F176": {
      "label": "Project full_name, websockets",
      "display": "Kludex/uvicorn",
      "asOf": "2026-11-20"
    },
    "F177": {
      "label": "Project stargazers_count, websockets",
      "display": "11.1K",
      "asOf": "2026-11-20"
    },
    "F178": {
      "label": "Library name, websocket-client",
      "display": "websocket-client",
      "asOf": "2026-11-20"
    },
    "F179": {
      "label": "Monthly downloads, websocket-client",
      "display": "185.6M",
      "asOf": "2026-11-20"
    },
    "F180": {
      "label": "License, websocket-client",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F181": {
      "label": "Package release, websocket-client",
      "display": "1.9.2",
      "asOf": "2026-11-20"
    },
    "F182": {
      "label": "Package release date, websocket-client",
      "display": "Aug 2026",
      "asOf": "2026-11-20"
    },
    "F183": {
      "label": "Install, websocket-client",
      "display": "python3 -m pip install websocket-client",
      "asOf": "2026-11-20"
    },
    "F184": {
      "label": "Quickstart, websocket-client",
      "display": "from websocket import create_connection\nws = create_connection(\"ws://echo.websocket.events/\")\nprint(ws.recv())\nprint(\"Sending 'Hello, World'...\")\nws.send(\"Hello, World\")\nprint(\"Sent\")\nprint(\"Receiving...\")\nresult =  ws.recv()\nprint(\"Received '%s'\" % result)\nws.close()\n",
      "asOf": "2026-11-20"
    },
    "F185": {
      "label": "Repository stars, websocket-client",
      "display": "3.7K",
      "asOf": "2026-11-20"
    },
    "F186": {
      "label": "Client API, websocket-client",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F187": {
      "label": "Server API, websocket-client",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F188": {
      "label": "Networking and concurrency role, websocket-client",
      "display": "Synchronous/threaded WebSocket client with low-level connection and callback options; not a WebSocket server.",
      "asOf": "2026-11-20"
    },
    "F189": {
      "label": "Project function, websocket-client",
      "display": "def create_websocket(configuration, url, headers=None):\n    enableTrace(False)\n\n    # We just need to pass the Authorization, ignore all the other\n    # http headers we get from the generated code\n    header = []\n    if headers and 'authorization' in headers:\n            header.append(\"authorization: %s\" % headers['authorization'])\n    if headers and 'sec-websocket-protocol' in headers:\n        header.append(\"sec-websocket-protocol: %s\" %\n                      headers['sec-websocket-protocol'])\n    else:\n        header.append(\"sec-websocket-protocol: %s,%s\" % (V5_CHANNEL_PROTOCOL, V4_CHANNEL_PROTOCOL))\n\n    if url.startswith('wss://') and configuration.verify_ssl:\n        ssl_opts = {\n            'cert_reqs': ssl.CERT_REQUIRED,\n            'ca_certs': configuration.ssl_ca_cert or certifi.where(),\n        }\n        if configuration.assert_hostname is not None:\n            ssl_opts['check_hostname'] = configuration.assert_hostname\n    else:\n        ssl_opts = {'cert_reqs': ssl.CERT_NONE}\n\n    if configuration.cert_file:\n        ssl_opts['certfile'] = configuration.cert_file\n    if configuration.key_file:\n        ssl_opts['keyfile'] = configuration.key_file\n    if configuration.tls_server_name:\n        ssl_opts['server_hostname'] = configuration.tls_server_name\n\n    websocket = WebSocket(sslopt=ssl_opts, skip_utf8_validation=False)\n    connect_opt = {\n         'header': header\n    }\n\n    if configuration.proxy or configuration.proxy_headers:\n        connect_opt = websocket_proxycare(connect_opt, configuration, url, headers)\n\n    websocket.connect(url, **connect_opt)\n    return websocket\n",
      "asOf": "2026-11-20"
    },
    "F190": {
      "label": "Project source file, websocket-client",
      "display": "kubernetes/stream/ws_client.py",
      "asOf": "2026-11-20"
    },
    "F191": {
      "label": "Project full_name, websocket-client",
      "display": "kubernetes-client/python",
      "asOf": "2026-11-20"
    },
    "F192": {
      "label": "Project stargazers_count, websocket-client",
      "display": "7.7K",
      "asOf": "2026-11-20"
    },
    "F193": {
      "label": "Library name, tornado",
      "display": "Tornado",
      "asOf": "2026-11-20"
    },
    "F194": {
      "label": "Monthly downloads, tornado",
      "display": "122.3M",
      "asOf": "2026-11-20"
    },
    "F195": {
      "label": "License, tornado",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F196": {
      "label": "Package release, tornado",
      "display": "6.6.1",
      "asOf": "2026-11-20"
    },
    "F197": {
      "label": "Package release date, tornado",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F198": {
      "label": "Install, tornado",
      "display": "python3 -m pip install tornado",
      "asOf": "2026-11-20"
    },
    "F199": {
      "label": "Quickstart, tornado",
      "display": "import asyncio\nfrom tornado.websocket import websocket_connect\nasync def main():\n    connection = await websocket_connect('ws://localhost:8765')\n    await connection.write_message('hello')\n    connection.close()\nasyncio.run(main())\n",
      "asOf": "2026-11-20"
    },
    "F200": {
      "label": "Official description, tornado",
      "display": "Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed.",
      "asOf": "2026-11-20"
    },
    "F201": {
      "label": "Quickstart source file, tornado",
      "display": "websocket.html",
      "asOf": "2026-11-20"
    },
    "F202": {
      "label": "Repository stars, tornado",
      "display": "22.2K",
      "asOf": "2026-11-20"
    },
    "F203": {
      "label": "Client API, tornado",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F204": {
      "label": "Server API, tornado",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F205": {
      "label": "Networking and concurrency role, tornado",
      "display": "Async networking/web framework with WebSocket server handlers and async client connections; distribution count includes non-WebSocket use.",
      "asOf": "2026-11-20"
    },
    "F206": {
      "label": "Download scope, tornado",
      "display": "Full framework distribution; WebSocket-specific users and overlap with dependencies cannot be inferred.",
      "asOf": "2026-11-20"
    },
    "F207": {
      "label": "Project function, tornado",
      "display": "def send_ping(self):\n    \"\"\"send a ping to keep the websocket alive\"\"\"\n    if self.ws_connection is None and self.ping_callback is not None:\n        self.ping_callback.stop()\n        return\n\n    if self.ws_connection.client_terminated:\n        self.close()\n        return\n\n    # check for timeout on pong.  Make sure that we really have sent a recent ping in\n    # case the machine with both server and client has been suspended since the last ping.\n    now = ioloop.IOLoop.current().time()\n    since_last_pong = 1e3 * (now - self.last_pong)\n    since_last_ping = 1e3 * (now - self.last_ping)\n    if since_last_ping < 2 * self.ping_interval and since_last_pong > self.ping_timeout:\n        self.log.warning(\"WebSocket ping timeout after %i ms.\", since_last_pong)\n        self.close()\n        return\n\n    self.ping(b\"\")\n    self.last_ping = now\n",
      "asOf": "2026-11-20"
    },
    "F208": {
      "label": "Project source file, tornado",
      "display": "jupyter_server/base/websocket.py",
      "asOf": "2026-11-20"
    },
    "F209": {
      "label": "Project full_name, tornado",
      "display": "jupyter-server/jupyter_server",
      "asOf": "2026-11-20"
    },
    "F210": {
      "label": "Project stargazers_count, tornado",
      "display": "573",
      "asOf": "2026-11-20"
    },
    "F211": {
      "label": "Library name, wsproto",
      "display": "wsproto",
      "asOf": "2026-11-20"
    },
    "F212": {
      "label": "Monthly downloads, wsproto",
      "display": "74.9M",
      "asOf": "2026-11-20"
    },
    "F213": {
      "label": "License, wsproto",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F214": {
      "label": "Package release, wsproto",
      "display": "1.3.2",
      "asOf": "2026-11-20"
    },
    "F215": {
      "label": "Package release date, wsproto",
      "display": "Nov 2025",
      "asOf": "2026-11-20"
    },
    "F216": {
      "label": "Install, wsproto",
      "display": "python3 -m pip install wsproto",
      "asOf": "2026-11-20"
    },
    "F217": {
      "label": "Quickstart, wsproto",
      "display": "from wsproto import WSConnection, ConnectionType\nfrom wsproto.events import Request\n",
      "asOf": "2026-11-20"
    },
    "F218": {
      "label": "Repository stars, wsproto",
      "display": "303",
      "asOf": "2026-11-20"
    },
    "F219": {
      "label": "Client API, wsproto",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F220": {
      "label": "Server API, wsproto",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F221": {
      "label": "Networking and concurrency role, wsproto",
      "display": "Sans-I/O WebSocket protocol state machine for both client and server roles; application owns concurrency and all network I/O.",
      "asOf": "2026-11-20"
    },
    "F222": {
      "label": "Network ownership, wsproto",
      "display": "No network I/O is performed. Application code feeds received bytes and sends bytes returned by send(event).",
      "asOf": "2026-11-20"
    },
    "F223": {
      "label": "Project function, wsproto",
      "display": "def send_500_response(self) -> None:\n    if self.response_started or self.handshake_complete:\n        return  # we cannot send responses anymore\n    headers: list[tuple[bytes, bytes]] = [\n        (b\"content-type\", b\"text/plain; charset=utf-8\"),\n        (b\"connection\", b\"close\"),\n        (b\"content-length\", b\"21\"),\n    ]\n    output = self.conn.send(wsproto.events.RejectConnection(status_code=500, headers=headers, has_body=True))\n    output += self.conn.send(wsproto.events.RejectData(data=b\"Internal Server Error\"))\n    self.transport.write(output)\n",
      "asOf": "2026-11-20"
    },
    "F224": {
      "label": "Project source file, wsproto",
      "display": "uvicorn/protocols/websockets/wsproto_impl.py",
      "asOf": "2026-11-20"
    },
    "F225": {
      "label": "Project full_name, wsproto",
      "display": "Kludex/uvicorn",
      "asOf": "2026-11-20"
    },
    "F226": {
      "label": "Project stargazers_count, wsproto",
      "display": "11.1K",
      "asOf": "2026-11-20"
    },
    "F227": {
      "label": "Library name, simple-websocket",
      "display": "simple-websocket",
      "asOf": "2026-11-20"
    },
    "F228": {
      "label": "Monthly downloads, simple-websocket",
      "display": "28.7M",
      "asOf": "2026-11-20"
    },
    "F229": {
      "label": "License, simple-websocket",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F230": {
      "label": "Package release, simple-websocket",
      "display": "1.1.0",
      "asOf": "2026-11-20"
    },
    "F231": {
      "label": "Package release date, simple-websocket",
      "display": "Oct 2024",
      "asOf": "2026-11-20"
    },
    "F232": {
      "label": "Install, simple-websocket",
      "display": "python3 -m pip install simple-websocket",
      "asOf": "2026-11-20"
    },
    "F233": {
      "label": "Quickstart, simple-websocket",
      "display": "from simple_websocket import Client\nws = Client.connect('ws://localhost:5000/echo')\nws.send('hello')\nws.close()\n",
      "asOf": "2026-11-20"
    },
    "F234": {
      "label": "Official description, simple-websocket",
      "display": "Provides a WebSocket server and client for Python.",
      "asOf": "2026-11-20"
    },
    "F235": {
      "label": "Quickstart source file, simple-websocket",
      "display": "intro.html",
      "asOf": "2026-11-20"
    },
    "F236": {
      "label": "Repository stars, simple-websocket",
      "display": "90",
      "asOf": "2026-11-20"
    },
    "F237": {
      "label": "Client API, simple-websocket",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F238": {
      "label": "Server API, simple-websocket",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F239": {
      "label": "Networking and concurrency role, simple-websocket",
      "display": "Sync/threaded and asyncio WebSocket client/server interfaces, including WSGI/ASGI integration; backend support has explicit constraints.",
      "asOf": "2026-11-20"
    },
    "F240": {
      "label": "WSGI network-socket support, simple-websocket",
      "display": "The documented Server API supports Werkzeug, Gunicorn, Eventlet, and Gevent socket extraction; it is not generic support for arbitrary WSGI hosts.",
      "asOf": "2026-11-20"
    },
    "F241": {
      "label": "Project function, simple-websocket",
      "display": "@wraps(f)\ndef websocket_route(*args, **kwargs):  # pragma: no cover\n    ws = Server(request.environ, **current_app.config.get(\n        'SOCK_SERVER_OPTIONS', {}))\n    try:\n        f(ws, *args, **kwargs)\n    except ConnectionClosed:\n        pass\n    try:\n        ws.close()\n    except:  # noqa: E722\n        pass\n\n    class WebSocketResponse(Response):\n        def __call__(self, *args, **kwargs):\n            if ws.mode == 'eventlet':\n                try:\n                    from eventlet.wsgi import WSGI_LOCAL\n                    ALREADY_HANDLED = []\n                except ImportError:\n                    from eventlet.wsgi import ALREADY_HANDLED\n                    WSGI_LOCAL = None\n\n                if hasattr(WSGI_LOCAL, 'already_handled'):\n                    WSGI_LOCAL.already_handled = True\n                return ALREADY_HANDLED\n            elif ws.mode == 'gunicorn':\n                raise StopIteration()\n            elif ws.mode == 'werkzeug':\n                return super().__call__(*args, **kwargs)\n            else:\n                return []\n\n    return WebSocketResponse()\n",
      "asOf": "2026-11-20"
    },
    "F242": {
      "label": "Project source file, simple-websocket",
      "display": "src/flask_sock/__init__.py",
      "asOf": "2026-11-20"
    },
    "F243": {
      "label": "Project full_name, simple-websocket",
      "display": "miguelgrinberg/flask-sock",
      "asOf": "2026-11-20"
    },
    "F244": {
      "label": "Project stargazers_count, simple-websocket",
      "display": "318",
      "asOf": "2026-11-20"
    },
    "F245": {
      "label": "Library name, trio-websocket",
      "display": "Trio WebSocket",
      "asOf": "2026-11-20"
    },
    "F246": {
      "label": "Monthly downloads, trio-websocket",
      "display": "27.8M",
      "asOf": "2026-11-20"
    },
    "F247": {
      "label": "License, trio-websocket",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F248": {
      "label": "Package release, trio-websocket",
      "display": "0.12.2",
      "asOf": "2026-11-20"
    },
    "F249": {
      "label": "Package release date, trio-websocket",
      "display": "Feb 2025",
      "asOf": "2026-11-20"
    },
    "F250": {
      "label": "Install, trio-websocket",
      "display": "python3 -m pip install trio-websocket",
      "asOf": "2026-11-20"
    },
    "F251": {
      "label": "Quickstart, trio-websocket",
      "display": "import trio\nfrom sys import stderr\nfrom trio_websocket import open_websocket_url\nasync def main():\n    try:\n        async with open_websocket_url('wss://echo.websocket.org') as ws:\n            await ws.send_message('hello world!')\n            message = await ws.get_message()\n            print('Received message: %s' % message)\n    except OSError as ose:\n        print('Connection attempt failed: %s' % ose, file=stderr)\ntrio.run(main)\n",
      "asOf": "2026-11-20"
    },
    "F252": {
      "label": "Official description, trio-websocket",
      "display": "Provides WebSocket support for Trio.",
      "asOf": "2026-11-20"
    },
    "F253": {
      "label": "Quickstart source file, trio-websocket",
      "display": "README.md",
      "asOf": "2026-11-20"
    },
    "F254": {
      "label": "Repository stars, trio-websocket",
      "display": "81",
      "asOf": "2026-11-20"
    },
    "F255": {
      "label": "Client API, trio-websocket",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F256": {
      "label": "Server API, trio-websocket",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F257": {
      "label": "Networking and concurrency role, trio-websocket",
      "display": "WebSocket client/server implementation with Trio-owned network I/O and wsproto framing; publisher currently describes life-support maintenance.",
      "asOf": "2026-11-20"
    },
    "F258": {
      "label": "Maintainer status, trio-websocket",
      "display": "This project is on life-support maintenance.",
      "asOf": "2026-11-20"
    },
    "F259": {
      "label": "Project function, trio-websocket",
      "display": "async def execute(self, cmd: Generator[dict, T, Any]) -> T:\n    \"\"\"Execute a command on the server and wait for the result.\n\n    Args:\n        cmd: any CDP command\n\n    Returns:\n        a CDP result\n    \"\"\"\n    cmd_id = next(self.id_iter)\n    cmd_event = trio.Event()\n    self.inflight_cmd[cmd_id] = cmd, cmd_event\n    request = next(cmd)\n    request[\"id\"] = cmd_id\n    if self.session_id:\n        request[\"sessionId\"] = self.session_id\n    request_str = json.dumps(request)\n    if logger.isEnabledFor(logging.DEBUG):\n        logger.debug(f\"Sending CDP message: {cmd_id} {cmd_event}: {request_str}\")\n    try:\n        await self.ws.send_message(request_str)\n    except WsConnectionClosed as wcc:\n        raise CdpConnectionClosed(wcc.reason) from None\n    await cmd_event.wait()\n    response = self.inflight_result.pop(cmd_id)\n    if logger.isEnabledFor(logging.DEBUG):\n        logger.debug(f\"Received CDP message: {response}\")\n    if isinstance(response, Exception):\n        if logger.isEnabledFor(logging.DEBUG):\n            logger.debug(f\"Exception raised by {cmd_event} message: {type(response).__name__}\")\n        raise response\n    return response\n",
      "asOf": "2026-11-20"
    },
    "F260": {
      "label": "Project source file, trio-websocket",
      "display": "py/private/cdp.py",
      "asOf": "2026-11-20"
    },
    "F261": {
      "label": "Project full_name, trio-websocket",
      "display": "SeleniumHQ/selenium",
      "asOf": "2026-11-20"
    },
    "F262": {
      "label": "Project stargazers_count, trio-websocket",
      "display": "34.6K",
      "asOf": "2026-11-20"
    }
  },
  "dataCheckedAt": "2026-11-20",
  "agent": {
    "exaCall": {
      "endpoint": "/search",
      "body": {
        "query": "Best Python WebSocket libraries websockets websocket-client python-socketio wsproto asyncio server client code examples",
        "numResults": 5
      },
      "docsUrl": "https://exa.ai/docs/reference/search"
    },
    "calls": []
  }
}
