{"id":8785,"library":"wsaccel","title":"wsaccel: WebSocket Accelerator","description":"wsaccel is a Python library that provides a WebSocket accelerator for `ws4py` and `AutobahnPython`. It replaces per-byte processing in these libraries with a faster Cython implementation, primarily for UTF-8 validation and payload masking. The project is currently at version 0.6.7, but its maintainer has indicated that it will cease active development due to its dependencies (ws4py and AutobahnPython) no longer being actively maintained. Users are advised to migrate to more actively supported WebSocket libraries like Tornado or websockets.","status":"deprecated","version":"0.6.7","language":"en","source_language":"en","source_url":"https://github.com/methane/wsaccel","tags":["websocket","performance","accelerator","cython","ws4py","autobahn"],"install":[{"cmd":"pip install wsaccel","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"wsaccel accelerates UTF-8 validation and masking operations in ws4py, if ws4py is installed.","package":"ws4py","optional":true},{"reason":"wsaccel accelerates UTF-8 validation and masking operations in AutobahnPython, if AutobahnPython is installed.","package":"AutobahnPython","optional":true},{"reason":"wsaccel provides a minor performance boost for UTF-8 validation and masking in websocket-client when available, without explicit patching.","package":"websocket-client","optional":true}],"imports":[{"note":"While Utf8Validator exists internally (used by websocket-client), the primary public API for acceleration is via `patch_autobahn()` or `patch_ws4py()`.","wrong":"from wsaccel import Utf8Validator","symbol":"wsaccel","correct":"import wsaccel\nwsaccel.patch_autobahn() # Or wsaccel.patch_ws4py()"}],"quickstart":{"code":"import wsaccel\n\n# To accelerate AutobahnPython:\n# import autobahn.websocket\n# wsaccel.patch_autobahn()\n# print('AutobahnPython patched by wsaccel.')\n\n# To accelerate ws4py:\n# import ws4py.server.cherrypyserver\n# wsaccel.patch_ws4py()\n# print('ws4py patched by wsaccel.')\n\nprint('wsaccel imported. Manual patching for target libraries is required if not automatically detected.')","lang":"python","description":"After installing `wsaccel`, it typically needs to be explicitly patched into `AutobahnPython` or `ws4py` to provide acceleration. For `websocket-client`, `wsaccel` is automatically used if present. The patching calls should be made before the target library processes WebSocket frames."},"warnings":[{"fix":"Plan to refactor your application to use a different WebSocket library (e.g., `websockets` or `Tornado`).","message":"The wsaccel project is explicitly marked by its maintainer as no longer actively maintained. Users are strongly advised to migrate to modern, actively maintained WebSocket libraries like Tornado or websockets.","severity":"deprecated","affected_versions":"0.6.7 and prior"},{"fix":"Consider using Python versions <= 3.9 if `wsaccel` is strictly necessary, or, preferably, migrate to an actively maintained WebSocket library that is compatible with newer Python versions.","message":"Building `wsaccel` with Python 3.10 and newer may fail due to the removal of the deprecated Python buffer protocol API (e.g., `PyObject_AsReadBuffer()`). This can lead to `ImportError` or build failures.","severity":"breaking","affected_versions":"Python 3.10+"},{"fix":"Ensure that `ws4py`, `AutobahnPython`, or `websocket-client` are installed alongside `wsaccel`, and for `ws4py`/`AutobahnPython`, apply the `patch_*()` calls as shown in the quickstart.","message":"Installing `wsaccel` alone does not provide any functionality. It acts as an accelerator for other WebSocket libraries. If those libraries are not installed or explicitly patched (for `ws4py`/`AutobahnPython`), `wsaccel` will have no effect.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"This issue indicates incompatibility with Python 3.10+. If you must use `wsaccel`, use Python 3.9 or earlier. The long-term solution is to migrate your application to a different, actively maintained WebSocket library that supports newer Python versions.","cause":"This `ImportError` during build or test is typically caused by `wsaccel`'s use of deprecated Python C API buffer protocols (e.g., `PyObject_AsReadBuffer`) which were removed in Python 3.10.","error":"ImportError: /builddir/build/BUILD/wsaccel-0.6.2/tests/test_4.py:2: in import wsaccel.utf8validator. E ImportError: /builddir/..."},{"fix":"Ensure `wsaccel` is installed and correctly patched into your `ws4py` or `AutobahnPython` application (e.g., `wsaccel.patch_ws4py()`). If using `websocket-client`, `wsaccel` is used automatically if available. This offloads the intensive operations to a faster Cython implementation.","cause":"Native Python implementations of UTF-8 validation and payload masking in libraries like `ws4py` and `AutobahnPython` can be CPU-intensive, leading to performance bottlenecks, particularly with frequent or large text-based WebSocket messages.","error":"My WebSocket server/client is slow, especially with large text messages."}]}