
Research
/Security News
npm Author Qix Compromised via Phishing Email in Major Supply Chain Attack
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
A Python client library for TLQ (Tiny Little Queue), a minimal message queue server written in Rust.
pip install tlq-client
from tlq_client import TLQClient
# Create client with default settings (localhost:1337)
client = TLQClient()
# Add a message to the queue
message_id = client.add_message("Hello, TLQ!")
print(f"Added message: {message_id}")
# Get messages from the queue
messages = client.get_messages(count=1)
for message in messages:
print(f"Received: {message.body} (ID: {message.id})")
# Process the message...
# Then delete it from the queue
client.delete_messages(message.id)
client = TLQClient(
host="localhost", # TLQ server hostname
port=1337, # TLQ server port
timeout=30.0, # Request timeout in seconds
max_retries=3 # Maximum retry attempts
)
You can also configure the client using environment variables:
TLQ_HOST
- Server hostname (default: localhost)TLQ_PORT
- Server port (default: 1337)TLQ_TIMEOUT
- Request timeout in seconds (default: 30.0)TLQ_MAX_RETRIES
- Maximum retry attempts (default: 3)export TLQ_HOST=queue.example.com
export TLQ_PORT=8080
export TLQ_TIMEOUT=60.0
export TLQ_MAX_RETRIES=5
python your_script.py
health_check() -> bool
Check if the TLQ server is healthy.
if client.health_check():
print("TLQ server is running")
else:
print("TLQ server is not available")
add_message(body: str) -> str
Add a message to the queue. Returns the message ID.
message_id = client.add_message("Process this task")
Note: Messages are limited to 64KB in size.
get_messages(count: int = 1) -> List[TLQMessage]
Retrieve messages from the queue.
# Get one message
messages = client.get_messages()
# Get multiple messages
messages = client.get_messages(count=5)
for message in messages:
print(f"ID: {message.id}")
print(f"Body: {message.body}")
print(f"State: {message.state}")
print(f"Retry Count: {message.retry_count}")
delete_messages(message_ids: Union[str, List[str]])
Delete processed messages from the queue.
# Delete single message
client.delete_messages(message_id)
# Delete multiple messages
client.delete_messages([id1, id2, id3])
retry_messages(message_ids: Union[str, List[str]])
Return messages to the queue for retry.
# Retry single message
client.retry_messages(message_id)
# Retry multiple messages
client.retry_messages([id1, id2, id3])
purge_queue()
Clear all messages from the queue.
client.purge_queue()
Message objects returned by get_messages()
:
@dataclass
class TLQMessage:
id: str # UUID v7 message identifier
body: str # Message content
state: str # Message state (e.g., "Ready", "Processing")
retry_count: int # Number of retry attempts
The client provides specific exception types for different error conditions:
from tlq_client import (
TLQError, # Base exception
TLQConnectionError, # Connection failures
TLQTimeoutError, # Request timeouts
TLQServerError, # Server errors (4xx, 5xx)
TLQValidationError # Client-side validation errors
)
try:
client.add_message("Hello, TLQ!")
except TLQValidationError as e:
print(f"Validation error: {e}")
except TLQConnectionError as e:
print(f"Connection error: {e}")
except TLQTimeoutError as e:
print(f"Timeout error: {e}")
except TLQServerError as e:
print(f"Server error: {e} (status: {e.status_code})")
except TLQError as e:
print(f"TLQ error: {e}")
The client can be used as a context manager to ensure proper cleanup:
with TLQClient() as client:
message_id = client.add_message("Hello!")
messages = client.get_messages()
# Session automatically closed when exiting context
from tlq_client import TLQClient
def produce_messages():
with TLQClient() as client:
for i in range(10):
message_id = client.add_message(f"Task {i}")
print(f"Queued task {i}: {message_id}")
if __name__ == "__main__":
produce_messages()
import time
from tlq_client import TLQClient, TLQError
def consume_messages():
with TLQClient() as client:
while True:
try:
messages = client.get_messages(count=5)
if not messages:
print("No messages available, sleeping...")
time.sleep(1)
continue
for message in messages:
try:
# Process the message
print(f"Processing: {message.body}")
time.sleep(0.1) # Simulate work
# Mark as completed
client.delete_messages(message.id)
print(f"Completed: {message.id}")
except Exception as e:
print(f"Failed to process {message.id}: {e}")
# Return to queue for retry
client.retry_messages(message.id)
except TLQError as e:
print(f"TLQ error: {e}")
time.sleep(5) # Back off on errors
if __name__ == "__main__":
consume_messages()
import os
from tlq_client import TLQClient
# Set environment variables
os.environ['TLQ_HOST'] = 'queue.myapp.com'
os.environ['TLQ_PORT'] = '8080'
os.environ['TLQ_TIMEOUT'] = '60'
# Client automatically picks up environment configuration
client = TLQClient()
print(f"Connected to {client.config.base_url}")
# Create virtual environment (recommended on macOS/Linux to avoid system Python restrictions)
python3 -m venv venv
# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
# venv\Scripts\activate
# Install development dependencies
pip install -e ".[dev]"
# Make sure virtual environment is activated
source venv/bin/activate
# Run tests
pytest
# Run tests with verbose output
pytest -v
# Run tests with coverage
pytest --cov=tlq_client --cov-report=html
# Run specific test file
pytest tests/test_client.py
# Run specific test
pytest tests/test_client.py::TestTLQClient::test_add_message_success
# Format code
black tlq_client tests
# Sort imports
isort tlq_client tests
# Lint code
flake8 tlq_client tests
# Type checking
mypy tlq_client
MIT License - see LICENSE file for details.
FAQs
Python client library for TLQ (Tiny Little Queue)
We found that tlq-client 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.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.