Skip to main content

Dataplicity Lomond

Tranquil WebSockets for Python.

PyPI version PyPI Coverage Status CI (modern) CI (legacy)

Lomond is a Websocket client which turns a websocket connection in to an orderly stream of events. No threads or callbacks necessary.

How to Use

To connect to a "ws:" or "wss:" WebSocket URL, construct a lomond.WebSocket object then iterate over it. This will yield an event object for each step in the connection process and for any data sent by the server.

You will receive a Binary or Text event when the server sends you a message. You may send a message with the send_binary or send_text methods.

TLS and Debugging

wss:// connections now verify TLS certificates by default. You can tune this without changing global SSL behavior:

ws = WebSocket(
    "wss://example.com/socket",
    ssl_verify=True,                 # default
    ssl_cafile="/etc/ssl/my-ca.pem", # optional custom CA bundle
)

For deep diagnostics, pass a trace callback and Lomond will emit structured records for connect, handshake, send/recv, and close stages:

def on_trace(record):
    print(record)

ws = WebSocket("wss://example.com/socket", trace=on_trace)

lomond.persist.persist() now also supports Retry-After from rejected upgrade responses (for example, 429 Too Many Requests) and will use that delay before reconnecting when present.

Testing and CI

The test suite now uses deterministic local socket fixtures for websocket, HTTP, and proxy scenarios (no public network dependencies required).

Modern CI runs on Python 3.8 through 3.13, and a separate legacy CI lane runs Python 2.7, 3.5, 3.6, and 3.7 in GitHub-hosted Docker jobs.

Developers do not need Docker locally to validate day-to-day changes; full legacy coverage is enforced in GitHub Actions.

PyPI Trusted Publisher (TPM)

This repository is configured to publish to PyPI via GitHub Actions OIDC Trusted Publishing with no API token.

Workflow file:

  • .github/workflows/pypi-publish.yml

PyPI Trusted Publisher form values:

  • Owner: wildfoundry
  • Repository name: dataplicity-lomond
  • Workflow name: pypi-publish.yml
  • Environment name: release

Before first release, create the GitHub environment named release in the repository settings.

Recommended hardening for the release environment:

  • require at least one reviewer approval before job execution
  • restrict deployment branch/tag patterns to trusted maintainers
  • keep admin bypass disabled for production releases

Publishing behavior:

  • Publish workflow runs when a GitHub Release is published.
  • Release tag must start with v and match lomond/_version.py.
  • You can also run the workflow manually via workflow_dispatch.

Example

The following is a silly example that connects to a websocket server (in this case a public echo server), and sends a string of text every 5 seconds.

from lomond import WebSocket


websocket = WebSocket('wss://echo.websocket.org')

for event in websocket:
    if event.name == 'poll':
        websocket.send_text('Hello, World')
    elif event.name == 'text':
        print(event.text)

Events

A successful websocket connection will result in a series of events such as the following:

┌──────────────────────┐
│      Connecting      │     Contacting server
└──────────────────────┘
           │
           ▼
┌──────────────────────┐     Connected to server (but
│      Connected       │     not yet sent data)
└──────────────────────┘
           │
           ▼
┌──────────────────────┐     Negotiated Websocket
│        Ready         │     handshake
└──────────────────────┘
           │  ┌───────────┐
           │  │           │
           ▼  ▼           │
┌──────────────────────┐  │  Send and receive
│ Binary / Text / Poll │──┘  application data
└──────────────────────┘
           │
           ▼
┌──────────────────────┐     Websocket close
│        Closed        │     handshake
└──────────────────────┘
           │
           ▼
┌──────────────────────┐
│     Disconnected     │     Disconnected TCP/IP
└──────────────────────┘     connection to server

Release files for lomond 0.3.4

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

Source distribution (sdist)

Source distribution for lomond 0.3.4
File Size Uploaded
lomond-0.3.4.tar.gz 50.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lomond 0.3.4
File Interpreter ABI Platform
lomond-0.3.4-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 88.1 kB

Release files / lomond-0.3.4.tar.gz

Download URL lomond-0.3.4.tar.gz
Size 50.9 kB
Tags Source
SHA-256 checksum
How to use checksums
250202a83ba45e3b265bf5dfef4db54d9c46b981230579dbe3b453dad320ba71
BLAKE2b-256 checksum
How to use checksums
76988118ebb05b6f1a3c45e8ebf0b7a745ce818919cc2c47ed9f68d01cd84b9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.

Transparency log

Release files / lomond-0.3.4-py2.py3-none-any.whl

Download URL lomond-0.3.4-py2.py3-none-any.whl
Size 37.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a63de62d1887e5038f51ce79b6aedbf31d4cac6e7cb135f592ddec9fff6a53cd
BLAKE2b-256 checksum
How to use checksums
26ce2738e533c379bff586902763e62432f37782da955f68d7bcc0f131edffe9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.4 This release

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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