Skip to main content

pondsocket-client

Python client for the PondSocket server. Connects to PondSocket servers (Python, Go, or TypeScript implementation) over WebSocket.

Modeled after the JavaScript client architecture (@eleven-am/pondsocket-client) rather than the Go one — the JS client fixes several bugs the Go client has (see Parity notes below).

Install

pip install pondsocket-client

Quick start

import asyncio
from pondsocket_client import PondClient


async def main() -> None:
    client = PondClient("ws://localhost:8000/ws", {"token": "secret"})
    await client.connect()

    channel = client.create_channel("/chat/42", {"username": "alice"})
    channel.on_message_event("message", lambda m: print(m.payload))
    channel.on_join(lambda user: print("joined:", user))
    channel.join()

    channel.send_message("message", {"text": "hello"})

    response = await channel.send_for_response("ping", {"text": "abc"})
    print("got pong:", response)

    await asyncio.sleep(10)
    await client.disconnect()


asyncio.run(main())

Architecture

BaseClient (abstract)
  ├── channel registry
  ├── inbound event routing (ACK / UNAUTHORIZED / CONNECTION / per-channel)
  ├── connection state machine: DISCONNECTED → CONNECTING → CONNECTED
  └── exponential reconnect

WebSocketClient(BaseClient)  (abstract)
  ├── opens via `websockets` library
  └── receive loop pumps inbound to BaseClient

PondClient(WebSocketClient)  (concrete)
  ├── URL handling (http → ws, https → wss)
  └── appends query-string params

The Channel class holds the per-channel state machine (IDLE → JOINING → JOINED → STALLED → CLOSED/DECLINED), a bounded FIFO outbound queue (raises ChannelQueueFullError on overflow), and a send_for_response that correlates inbound replies by requestId.

Connection states

Subscribe via client.on_connection_change(handler):

State When
DISCONNECTED initial; after disconnect or socket close
CONNECTING connect() called; socket handshake in flight
CONNECTED socket open AND server sent the CONNECTION event

Channel states

Subscribe via channel.on_channel_state_change(handler):

State Meaning
IDLE created but join() not called
JOINING join() called; awaiting ACKNOWLEDGE
JOINED server acknowledged; messages flow
STALLED socket dropped while JOINED; will rejoin on reconnect
CLOSED leave() called
DECLINED server sent UNAUTHORIZED; channel is terminal — create a new one

Parity notes

Compared to the Go client (go/pondsocket-client/):

Behavior Go Python
send_for_response correlation event name (buggy) requestId (correct)
Reconnect backoff linear despite comment true exponential, capped
UNAUTHORIZED handling not implemented → DECLINED state
Connection state bool (no CONNECTING) three-state enum
Outbound queue unbounded bounded FIFO, raises on overflow
Join while disconnected dropped silently deferred until CONNECTED

The Python client follows the JS client design where the two diverge.

Public API

from pondsocket_client import (
    PondClient,
    Channel,
    ConnectionState,
    ClientOptions,
    ChannelQueueFullError,
    ResponseTimeoutError,
)

Also exposed for adapter authors: BaseClient, WebSocketClient, Publisher (type alias).

License

GPL-3.0-or-later.

Metadata

Release files for pondsocket-client 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pondsocket-client 0.0.7
File Size Uploaded Provenance Actions
pondsocket_client-0.0.7.tar.gz 16.8 kB Without provenance Details for pondsocket_client-0.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pondsocket-client 0.0.7
File Interpreter ABI Platform Actions
pondsocket_client-0.0.7-py3-none-any.whl Python 3 none any Details for pondsocket_client-0.0.7-py3-none-any.whl

Total release size: 29.6 kB

Release files / pondsocket_client-0.0.7.tar.gz

Download URL pondsocket_client-0.0.7.tar.gz
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e1c85598c65792bcfc6d4d2bae1270981c47783919d75961c1c526f3906b28a7
BLAKE2b-256 checksum
How to use checksums
7ec5983586b4a6af71ae58d2782dce53fc703c02cbbbf784d08a91affcd1158a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.0

Release files / pondsocket_client-0.0.7-py3-none-any.whl

Download URL pondsocket_client-0.0.7-py3-none-any.whl
Size 12.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e5593f9309caa938e32d6c98f0a822c000a5e586ae1d263bda1b19a4229faab4
BLAKE2b-256 checksum
How to use checksums
531151fb4f8c723d4a9b21e828724e44fee16c72e8fb88b9347c6d48dc752c7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.0

Security for pondsocket-client 0.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page