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.2.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.2.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

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

Hashes for superbright_jobpoller-0.2.0.tar.gz
Algorithm Hash digest
SHA256 484d1eb619af4d86ccd1c45e1acb85e7ef735e046f6da96b4442bf22c425744e
MD5 5c9dc72ac45b89a8fb687f32e6e95ca6
BLAKE2b-256 d8865d7908ba9681e678dfd6aedc26e6a10f25dd874f155fc31a90cf43d95ebe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for superbright_jobpoller-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 12a4e67f988b2aa23c40d08b515f0f3826afa82e35ebae15ec0db201f43cb9e3
MD5 cf9335a03af455bb1d239454bf480132
BLAKE2b-256 01a0a4e578cdf681606a445aba0030f48ef064c2f7339f0bc5fabb36eb69baf8

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