Lazy Socket
An attempt at creating a websocket based communication system that handles all the threading and async stuff in the background.
Installation
pip install lazy-socket
Usage
Server
The server can be created by subclassing LazyServer and implementing the process_message method. This is an async method that will be called whenever a message is received from a client. To respond to the client, use the send method of the client object passed to the method. A list of clients is available via the clients attribute of the server.
import asyncio
from lazy_socket.server import LazyServer
class Server(LazyServer):
async def process_message(self, client, message):
await client.send(f"Received: {message}")
if __name__ == "__main__":
server = Server(name="TestServer", host="0.0.0.0", port=5000, version="1.0")
try:
server.start()
except KeyboardInterrupt:
print("Shutting down server...")
Client
The client can be created by instantiating the LazyClient class. The client has a queue attribute that can be used to receive messages from the server. The client must be started using the start method. Messages can be sent to the server using the send method.
A message lazy_client:connected:{uri} is sent to the queue when the client successfully connects to the server.
from lazy_socket.client import LazyClient
client = LazyClient()
client.start()
while True:
if client.queue.empty():
continue
message = client.queue.get()
if message.startswith("lazy_client:connected:"):
client.send("Hello, Lazy Server!")
Metadata
Release files for lazy-socket 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lazy_socket-0.0.7.tar.gz | 5.4 kB | Without provenance | Details for lazy_socket-0.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lazy_socket-0.0.7-py3-none-any.whl | Python 3 | none | any | Details for lazy_socket-0.0.7-py3-none-any.whl |
Total release size: 11.9 kB
Release files / lazy_socket-0.0.7.tar.gz
| Download URL | lazy_socket-0.0.7.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac81c0d3339dc09ab14169ff41880e6ae316c46fa070afae4ab4eec12d234ad8
|
|
BLAKE2b-256 checksum How to use checksums |
57e70e1a28a8754c58af5430b5004eec2eb6a559e7dcd52c9a57b4420edd8af2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / lazy_socket-0.0.7-py3-none-any.whl
| Download URL | lazy_socket-0.0.7-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8b3f80f34d4375d79bd995a98a339690b82a21fddcc0922dc7d9562b553de363
|
|
BLAKE2b-256 checksum How to use checksums |
67b049c45d46bf2c732dd971b264c0745427da983d44efef615098a73d92b386
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for lazy-socket 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.