
Product
Socket Now Supports pylock.toml Files
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
A library for coordinated client-server communication using a queue-based approach.
The QueueSync is a Python library for coordinating and managing distributed systems. It consists of a Coordinator (server) that queues and processes client requests sequentially, and Worker (client) instances that send requests to the Coordinator. This library is structured to support multi-machine coordination in a networked environment.
Coordinator
class queues client requests, handling them one at a time.Coordinator
and Worker
.The project is organized as follows:
QueueSync/
├── src/
│ ├── __init__.py
│ ├── coordinator.py
│ └── worker.py
├── tests/
│ ├── __init__.py
│ ├── test_coordinator.py
│ └── test_worker.py
├── .gitignore
├── LICENSE
├── README.md
├── setup.py
└── pyproject.toml
Clone the repository and ensure you have Python 3.x installed. Optionally, set up a virtual environment:
git clone https://github.com/yourusername/inter-machine-coordinator-library.git
cd inter-machine-coordinator-library
python3 -m venv .venv
source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
The Coordinator class
, located in src/coordinator.py
, is an abstract class that serves as the server, managing client connections and processing requests from a queue.
start()
: Initializes and starts the server.queue_client_request(client_socket, client_address)
: Adds client requests to a queue.Process_requests()
: Sequentially processes each queued request.handle_request(client_socket, client_address, received_data)
: Abstract method to be implemented for custom request processing.The Worker
class, located in src/worker.py
, is an abstract class representing the client, which connects to the Coordinator
server, sends requests, and receives responses.
start()
: Connects the Worker to the Coordinator server.query_coordinator(data)
: Sends data to the server and awaits a response.run_worker()
: Abstract method to be implemented for custom worker logic.To implement specific request handling and worker functionality, create subclasses of Coordinator
and Worker
, then override the handle_request
and run_worker
methods, respectively.
Example:
from src.coordinator import Coordinator
from src.worker import Worker
class MyCoordinator(Coordinator):
def handle_request(self, client_socket, client_address, received_data):
response = b"Custom response data"
return response
class MyWorker(Worker):
def run_worker(self):
data = b"Sample request data"
response = self.query_coordinator(data)
print(f"Received response: {response}")
Coordinator:
coordinator = MyCoordinator(host='127.0.0.1', port=12345, max_num_of_clients=5, are_updates_displayed=True)
coordinator.start()
Worker:
worker = MyWorker(host='127.0.0.1', port=12345, are_updates_displayed=True)
worker.start()
This example demonstrates a simple setup with a Coordinator
listening on localhost and a custom Worker
connecting to it.
This library is open-source and available under the Apache License 2.0. See the LICENSE
file for details.
FAQs
A library for coordinated client-server communication using a queue-based approach.
We found that queuesync demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.
Research
Security News
Malicious Ruby gems typosquat Fastlane plugins to steal Telegram bot tokens, messages, and files, exploiting demand after Vietnam’s Telegram ban.