Registry / http-networking / lomond

lomond

JSON →
library0.3.3pypypi✓ verified 23d ago

Lomond is a Pythonic WebSocket client library designed for reliability and ease of use, turning a WebSocket connection into an orderly stream of events. It distinguishes itself by providing an event-driven model without requiring explicit threads or callbacks for basic usage. The current version is 0.3.3. However, the library appears to be abandoned, with the last release in 2018 and no recent development activity.

pip install lomond
INSTALL
IMPORT
SIG · LOMOND
L
lomond
http-networkingpythonv0.3.3
Install
1.6s avg
Import
104ms
Disk
69MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.110s · 71.1MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.6s · import 0.098s · 19MB
69MB installed
● package 69MB
Code
Verified usage

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

WebSocket
from lomond import WebSocket
from lomond.websocket import WebSocket
While 'from lomond.websocket import WebSocket' also works, the official quickstart and many examples use 'from lomond import WebSocket' for brevity and consistency.

This example demonstrates how to establish a WebSocket connection using Lomond, send a text message, and print received text messages. Lomond provides an event-driven loop where different `event.name` values indicate connection status or received data. The loop will terminate upon disconnection or explicit `break`.

import os from lomond import WebSocket # Using a public echo server for demonstration. # Replace with your actual WebSocket URL. websocket = WebSocket(os.environ.get('LOMOND_WS_URL', 'wss://echo.websocket.org')) print(f"Connecting to {websocket.url}...") for event in websocket: if event.name == 'ready': print('WebSocket connection established. Sending a message...') websocket.send_text('Hello from Lomond!') elif event.name == 'text': print(f'Received: {event.text}') # Optionally close after receiving a message websocket.close() break elif event.name == 'disconnected': print(f'Disconnected: {event.reason}') break else: # Other events like 'connecting', 'connected', 'poll', 'closing' might occur. # print(f'Event: {event.name}') pass
Debug
Known issues
breakingThe library's last release was in 2018 with explicit Python 3.7 compatibility. It is unlikely to be compatible with newer Python versions (3.8+ onwards, especially 3.12) due to significant changes and deprecations in the Python language and standard library over the years (e.g., removal of `distutils`, changes to Unicode handling). Users attempting to run Lomond on modern Python versions may encounter `ImportError` or other runtime errors.
fix
Consider using alternative, actively maintained WebSocket client libraries for Python (e.g., `websockets`, `websocket-client`) that are tested and compatible with modern Python versions. If you must use Lomond, restrict your environment to Python 3.7 or earlier, but be aware of the security implications of using an End-of-Life Python version.
affects: 0.3.3 and earlier on Python 3.8+
gotchaLomond is an abandoned library. There are no indications of ongoing maintenance, bug fixes, or security updates. Using an unmaintained library can introduce security vulnerabilities and compatibility issues with other modern packages or operating systems.
fix
For new projects, strongly consider using an actively maintained WebSocket client library. For existing projects using Lomond, assess the risks, consider migrating to a current library, or be prepared to maintain any necessary fixes internally.
affects: 0.3.3 and earlier
gotchaUnhandled exceptions within the event loop will cause Lomond to disconnect the socket without performing a graceful WebSocket closing handshake. This can lead to unexpected client or server state.
fix
Always wrap your event handling logic in `try...except` blocks within the `for event in websocket:` loop to catch and handle exceptions gracefully, ensuring explicit `websocket.close()` calls if necessary.
affects: All versions
gotchaWhile Lomond's `WebSocket` objects are explicitly stated as thread-safe, the library itself does not launch any threads for its core operation. If your application requires concurrent processing beyond simple event handling, you will need to manage threading yourself (e.g., running the WebSocket loop in a separate thread).
fix
If your application needs to perform long-running tasks or concurrent I/O alongside WebSocket communication, encapsulate the Lomond event loop within its own dedicated thread to prevent blocking the main application thread.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'lomond'
The 'lomond' library is not installed in the Python environment from which the code is being executed, or the environment is not correctly configured.
fix
Install the library using pip: `pip install lomond`
json.decoder.JSONDecodeError: Extra data: line 1 column 2 (char 1)
The WebSocket server sent a message that `lomond` attempted to interpret as JSON, but the message either contained non-JSON data, was malformed, or was prefixed with non-JSON protocol information (e.g., Socket.IO framing).
fix
Inspect the raw `event.text` from the WebSocket event to understand the actual message format. If the server is not sending pure JSON, custom parsing logic will be required. For `socket.io` connections, specialized client libraries might be necessary.
AttributeError: 'Text' object has no attribute 'json'
This error occurs when attempting to access the `.json` attribute of a `Text` event, but the content of the `Text` event is not valid JSON, causing the `.json` attribute to not be populated or to raise an error during parsing, or if the event is not a `Text` event at all.
fix
Ensure that the received `Text` event actually contains valid JSON before attempting to access `event.json`. It's good practice to check `event.name` to confirm the event type and potentially use a `try-except json.JSONDecodeError` block when accessing `event.json`, or explicitly check if `event.json` is not `None`.
Upgrade
Version history
0.3.3latest on PyPI · released Sep 21, 2018
Audit
Dependencies
sixrequiredRequired for Python 2/3 compatibility, though primarily for older Python 3 versions given the project's age.
wsacceloptionalOptional C module for optimizing some WebSocket operations, Lomond will use it if available.
Agent activity
5 hits · last 30 days
node
4
Resources
lomond — pip install lomond · libregistry