Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

superbright_jobpoller-0.3.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

superbright_jobpoller-0.3.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file superbright_jobpoller-0.3.0.tar.gz.

File metadata

  • Download URL: superbright_jobpoller-0.3.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

Hashes for superbright_jobpoller-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c257c019a95f64045ce9bcf973704764e470a05e9ae51c30037449737d3ba00f
MD5 a1ebeddbba95ad6482d036bf4cff9dce
BLAKE2b-256 64ce20f7ff50d413e40840421b2780c225fbaaf552239d045bf95713406116e9

See more details on using hashes here.

File details

Details for the file superbright_jobpoller-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for superbright_jobpoller-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b8957f8a1a9b78ace0fbf65154f9ffd30513f638a67e0776f16aa787f723f9ea
MD5 887c53f23fd6a7ecb8c3807931928a78
BLAKE2b-256 736627dce639e406dd976db5c82a166e4f54a5583322e74da9c8418ccda5c351

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page