A library for polling and processing jobs from API endpoints
Project description
JobPoller
A Python library for polling and processing jobs from API endpoints.
Installation
pip install superbright-jobpoller
Features
- Configurable API endpoints and authentication
- Flexible job processing with customizable scripts
- Robust logging and error handling
- Simple interface for creating job processing services
Usage
Basic Usage
from jobpoller import JobProcessor, JobConfig
# Create configuration
config = JobConfig(
api_url="https://api.example.com",
api_key="your-api-key",
poll_endpoint="/queue/next",
log_dir="queue_logs"
)
# Create job processor
processor = JobProcessor(
config=config,
logger_name="QueueProcessor",
process_script="process_job.py",
script_executor="python"
)
# Run the processor
processor.run()
Custom Job Processing
from jobpoller import JobProcessor, JobConfig
# Create configuration
config = JobConfig(
api_url="https://api.example.com",
api_key="your-api-key",
poll_endpoint="/renders/next",
log_dir="render_logs"
)
# Custom job parser function
def parse_render_job(job_data):
job_id = job_data.get("msgId")
message = json.loads(job_data.get("message"))
return {
"job_id": job_id,
"floorPlanId": message.get("floorPlanId"),
"styleId": message.get("styleId")
}
# Create job processor
processor = JobProcessor(
config=config,
logger_name="RenderProcessor",
process_script="process_blend_automated.sh",
script_executor="bash",
job_parser=parse_render_job
)
# Run the processor
processor.run()
Publish the package:
python -m build
twine upload dist/*
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file superbright_jobpoller-0.2.0.tar.gz.
File metadata
- Download URL: superbright_jobpoller-0.2.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
484d1eb619af4d86ccd1c45e1acb85e7ef735e046f6da96b4442bf22c425744e
|
|
| MD5 |
5c9dc72ac45b89a8fb687f32e6e95ca6
|
|
| BLAKE2b-256 |
d8865d7908ba9681e678dfd6aedc26e6a10f25dd874f155fc31a90cf43d95ebe
|
File details
Details for the file superbright_jobpoller-0.2.0-py3-none-any.whl.
File metadata
- Download URL: superbright_jobpoller-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12a4e67f988b2aa23c40d08b515f0f3826afa82e35ebae15ec0db201f43cb9e3
|
|
| MD5 |
cf9335a03af455bb1d239454bf480132
|
|
| BLAKE2b-256 |
01a0a4e578cdf681606a445aba0030f48ef064c2f7339f0bc5fabb36eb69baf8
|