{"id":5654,"library":"lomond","title":"Lomond","description":"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.","status":"abandoned","version":"0.3.3","language":"en","source_language":"en","source_url":"https://github.com/wildfoundry/dataplicity-lomond","tags":["websocket","client","network","event-driven"],"install":[{"cmd":"pip install lomond","lang":"bash","label":"Install latest version"},{"cmd":"pip install wsaccel","lang":"bash","label":"Install optional C optimizations"}],"dependencies":[{"reason":"Required for Python 2/3 compatibility, though primarily for older Python 3 versions given the project's age.","package":"six","optional":false},{"reason":"Optional C module for optimizing some WebSocket operations, Lomond will use it if available.","package":"wsaccel","optional":true}],"imports":[{"note":"While 'from lomond.websocket import WebSocket' also works, the official quickstart and many examples use 'from lomond import WebSocket' for brevity and consistency.","wrong":"from lomond.websocket import WebSocket","symbol":"WebSocket","correct":"from lomond import WebSocket"}],"quickstart":{"code":"import os\nfrom lomond import WebSocket\n\n# Using a public echo server for demonstration.\n# Replace with your actual WebSocket URL.\nwebsocket = WebSocket(os.environ.get('LOMOND_WS_URL', 'wss://echo.websocket.org'))\n\nprint(f\"Connecting to {websocket.url}...\")\n\nfor event in websocket:\n    if event.name == 'ready':\n        print('WebSocket connection established. Sending a message...')\n        websocket.send_text('Hello from Lomond!')\n    elif event.name == 'text':\n        print(f'Received: {event.text}')\n        # Optionally close after receiving a message\n        websocket.close()\n        break\n    elif event.name == 'disconnected':\n        print(f'Disconnected: {event.reason}')\n        break\n    else:\n        # Other events like 'connecting', 'connected', 'poll', 'closing' might occur.\n        # print(f'Event: {event.name}')\n        pass\n","lang":"python","description":"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`."},"warnings":[{"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.","message":"The 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.","severity":"breaking","affected_versions":"0.3.3 and earlier on Python 3.8+"},{"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.","message":"Lomond 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.","severity":"gotcha","affected_versions":"0.3.3 and earlier"},{"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.","message":"Unhandled 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"While 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).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}