Registry / http-networking / python-jsonrpc-server

python-jsonrpc-server

JSON →
library0.4.0pypypiunverified

A JSON RPC 2.0 server library for Python, used primarily by language servers like the Python Language Server. Current version 0.4.0, with infrequent updates. Supports concurrent request handling via futures.

pip install python-jsonrpc-server
INSTALL
IMPORT
SIG · PYTHON-JSONRPC-SER
P
python-jsonrpc-server
http-networkingpythonv0.4.0
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.

JSONRPC2Protocol
from pyls_jsonrpc.manager import JSONRPC2Protocol
from jsonrpc.manager import JSONRPC2Protocol

Basic JSON RPC 2.0 server that reads from stdin and writes to stdout, handling a 'hello' method.

import asyncio from jsonrpc.server import JSONRPC2Server from jsonrpc.manager import JSONRPC2Protocol async def handle_request(protocol, data): request = protocol.parse_request(data) if request.method == "hello": response = protocol.create_response(request, "world") return response.serialize() else: error = protocol.create_error_response(request, -32601, "Method not found") return error.serialize() server = JSONRPC2Server(handle_request) asyncio.run(server.run()) print("Server running on stdin/stdout")
Debug
Known issues
breakingIn version 0.3.0, the built-in `json` module was replaced with `ujson`. This may cause compatibility issues if your code depends on custom JSON encoders/decoders or uses different JSON library features. `ujson` is not available by default on Windows; install it separately or use a workaround.
fix
If you need the standard json module, pin to version 0.2.0 or manually monkey-patch. On Windows, install ujson with pip install ujson.
affects: >=0.3.0
gotchaThe library's protocol expects a specific JSON RPC 2.0 format. If you send malformed requests (e.g., missing 'jsonrpc' field or invalid id), the server may hang or raise cryptic errors.
fix
Ensure your JSON RPC messages strictly follow the spec: include 'jsonrpc':'2.0', 'method', 'id' (or null for notifications), and proper 'params'.
affects: all
Upgrade
Version history
0.4.0latest on PyPI · released Sep 8, 2020
Audit
Dependencies
ujsonoptionalUsed for faster JSON serialization (optional on Windows)
futureoptionalRequired for Python 2 compatibility
Agent activity
14 hits · last 30 days
node
14
Resources
python-jsonrpc-server — pip install python-jsonrpc-server · libregistry