Skip to main content

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

jobs = queue.jobs  ## List of jobs in queue object

Running Jobs

while queue.jobs:
    jobs = queue.jobs
    for job in jobs:
        job.run(function) ## run any function

function can be any function to run for this job Using the while loop allows any new jobs placed on the queue while processing to be carried out next.

Passing Params

To pass params in laravel to the python function, specify a param_map in the run function.

# laravel:
$this->groupId = 12;

# python
def function(group_id):
    pass

job.run(function, param_map={
    'groupId': 'group_id'
})

Additionally, you can specify a cache_lock_uid This can be either a str or a list of strings. This is to be used for managing the job cache if you are using the ShouldBeUnique or ShouldBeUniqueUntilProcessing properties in Laravel The cache_lock_uid should resemble what you have set uniqueId() to in laravel. If a list is sent, you can specify parameters to be filled with $:

# Laravel:
$this->param1 = 1
$this->param2 = 2

public function uniqueId(): string
    {
        return $this->param1 . '-' . $this->param2;
    }


# Python
job.run(function_name,
    param_map = {
        'param1': 'param1',
        'param2': param2'
    }
    cache_lock_uid = ['$param1', '-', '$param2'])

## $param1 and $param2 will be swapped in with the cooresponding value.

To use cache locks, you must specify the database as your cache for queue. You can do this as so:

public function uniqueVia(): Repository
    {
        return Cache::driver('database');
    }

If using the ShouldBeUniqueUntilProcessing property, you must specify that in you job runner as well. By default (unique_until_processing=False), the cache lock will be relased after processing, emulating the ShouldBeUnique laravel property. Setting this unique_until_processing=True will relase this lock at the start of the job, like ShouldBeUniqueUntilProcessing

Release files for laravel-queue 0.0.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for laravel-queue 0.0.16
File Size Uploaded
laravel_queue-0.0.16.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for laravel-queue 0.0.16
File Interpreter ABI Platform
laravel_queue-0.0.16-py3-none-any.whl Python 3 none any Details

Total release size: 11.2 kB

Release files / laravel_queue-0.0.16.tar.gz

Download URL laravel_queue-0.0.16.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4a9b5b957df06ca4018e197dba57d3d72bbe2c5c9d8864ebd5365ea07e0bf094
BLAKE2b-256 checksum
How to use checksums
e859c722a5dc2547fde3cdb11b0be11e64d90ff6654fb660013096baac293620
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / laravel_queue-0.0.16-py3-none-any.whl

Download URL laravel_queue-0.0.16-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31982fef3b139371267500d3cd14c067e33aef1e40d9ba421caf2fa801e24431
BLAKE2b-256 checksum
How to use checksums
23de8beab5c7ef620c061ecf5c6e0069de46793955d26e617aab5b9047164ba4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.16 This release

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page