Skip to main content

Reads from a Laravel queue

Project description

Laravel Queue for Python

Currently:

  • only supports reading
  • only supports queues in postgres

Create a Queue Object

from laravel_queue import Queue

connection_string = "postgresql://user:password@host:5432/db"
queue = Queue(connection_string)

Queue Args:

connection: str or sqlalchemy.engine.base.Engine
queue: str, default 'python', the queue name in the database
jobs_table: str, default 'jobs.jobs', the table name for the jobs
failed_jobs_table: str, default 'jobs.failed_jobs', the table name for the failed jobs

Read Jobs from Queue

queue.read()  ## List of jobs returned, or:
jobs = queue.jobs  ## List of jobs in queue object

Running Jobs

for job in queue.jobs:
    job.run(function, arg, kwarg=kwarg)  ## run any function and pass any args to it

function can be any function to run for this job any args and kwargs will be used in this function

EX:

job.run(print, job.id)

Output: 12345

Jobs run in this way will be:

  • removed from the jobs table and the queue object when complete (regardless of pass or fail)
  • if failed, added to the failed jobs table along with the exception and a timestamp

Managing Jobs Manually

For some reason, you may want to manage the job state yourself. (bypassing the run function above)

## Job failed
job.fail(exception) # Takes a string of the exception message, and fails the job. (both in the db and the queue)

## Job success
job.complete()  # Removes from job table and queue object

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

laravel_queue-0.0.12.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

laravel_queue-0.0.12-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file laravel_queue-0.0.12.tar.gz.

File metadata

  • Download URL: laravel_queue-0.0.12.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for laravel_queue-0.0.12.tar.gz
Algorithm Hash digest
SHA256 fb12f5012a28605b1a7d559fa66d6bbb43e061e9b77fa1009dc8ec1556eed3fb
MD5 dd07c8b23e20f583d65bd38616e23f9b
BLAKE2b-256 8537824ba28957aa64df49db93d6d835e16cc3a7bef35666f95f503fef730a5c

See more details on using hashes here.

File details

Details for the file laravel_queue-0.0.12-py3-none-any.whl.

File metadata

File hashes

Hashes for laravel_queue-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 27d6ed516a6a5020a3fbd88cdcd0e62eba03390ba2375295f70d75cdd6c88208
MD5 3ce5d84e1781c38b8da0bc65df0da928
BLAKE2b-256 8ab8f4557243d2f179e5772277cbaecca894179b15d432188e8693f3e0e34e6c

See more details on using hashes here.

Supported by

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