Registry / devops / picows

picows

JSON →
library2.1.1pypypi✓ verified 83d ago

Picows is an ultra-fast WebSocket client and server library for asyncio, built on top of Cython. Version 2.1.1 requires Python >=3.9. It is actively maintained with regular releases.

pip install picows
INSTALL
IMPORT
SIG · PICOWS
P
picows
devopspythonv2.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

WSListener
from picows import WSListener
Main listener class for creating WebSocket handlers.
WSFrame
from picows import WSFrame
Frame type used in callbacks.
WSMsgType
from picows import WSMsgType
Enum for message types (TEXT, BINARY, CLOSE, etc.).
ws_connect
from picows import ws_connect
Client connection function.
WsServer
from picows import WsServer
picows.ws_server
Server class exported directly, not a module.
serve_ws
from picows import serve_ws
Convenience function to create and run a server.

Connect to a WebSocket echo server, send a message, and print any received text frames.

import asyncio from picows import WSListener, WSFrame, ws_connect, WSMsgType class MyListener(WSListener): def on_ws_connected(self, transport): print("Connected") def on_ws_frame(self, transport: WSFrame): if transport.msg_type == WSMsgType.TEXT: print(f"Received: {transport.get_text()}") elif transport.msg_type == WSMsgType.CLOSE: print("Server closed connection") async def main(): transport = await ws_connect("ws://echo.websocket.org", MyListener) await transport.send_text("Hello") await asyncio.sleep(2) asyncio.run(main())
Debug
Known issues
gotchaDo not block the event loop inside WSListener callbacks (e.g., on_ws_frame). Callbacks are called from the transport's event loop context; blocking will freeze the connection.
fix
Use asyncio.create_task for any long-running operations.
affects: all
breakingIn version 2.x, the API changed significantly from 1.x. The listener class replaced simple callbacks. Upgrade triggers breaking changes in existing code.
fix
Migrate from callback functions to a WSListener subclass. Refer to the migration guide in the GitHub README.
affects: >=2.0.0
deprecatedThe 'picows.ws_server' function is deprecated as of version 2.1.0. Use 'serve_ws' instead.
fix
Replace 'picows.ws_server' with 'serve_ws' from the picows module.
affects: >=2.1.0
gotchaWhen using wss:// (SSL), ensure the asyncio loop is properly configured (e.g., with SSL context). For self-signed certificates, you may need to provide an SSLContext with verify_mode=ssl.CERT_NONE.
fix
Pass an ssl context in ws_connect: ws_connect(url, MyListener, ssl=ssl_context)
affects: all
Errors
Common errors & fixes
AttributeError: module 'picows' has no attribute 'ws_server'
Using deprecated or removed function 'ws_server'. It was renamed to 'serve_ws' in version 2.1.0.
fix
Use 'from picows import serve_ws' and call serve_ws(...).
TypeError: object NoneType can't be used in 'await' expression
Attempting to await a method that returns None, e.g., forgetting to return a coroutine from a WSListener method.
fix
Ensure that WSListener methods that should be awaitable (like on_ws_connected) are defined with async def.
ImportError: cannot import name 'ws_connect' from 'picows'
Incorrect import path or outdated version. ws_connect is exported from picows since version 2.0.
fix
Upgrade to picows >=2.0.0 with 'pip install --upgrade picows' and use 'from picows import ws_connect'.
Upgrade
Version history
2.1.1latest on PyPI · released Jun 5, 2026
Audit
Dependencies
cythonoptionalCompilation dependency for building from source, but wheels are provided.
Agent activity
2 hits · last 30 days
node
2
Resources
picows — pip install picows · libregistry