Sync Laravel queue with Python - simple and lightweight.
Project description
LaraQueue
Простая и легковесная синхронизация очередей между Python и Laravel через Redis. Обрабатывайте задачи Laravel в Python и наоборот.
English: Queue sync between Python and Laravel using Redis driver. You can process jobs dispatched from Laravel in Python.
Fork Notice: This package is a fork of the original python-laravel-queue by @sinanbekar. This version includes critical bug fixes, comprehensive tests, and updated compatibility with newer dependencies.
NOTE: This package is in beta and only Redis is supported currently. Production usage is not recommended until stable release.
Установка / Install
pip install LaraQueue
Usage
- Прослушивание задач в Python / Listen for jobs on Python:
from lara_queue import Queue
from redis import Redis
r = Redis(host='localhost', port=6379, db=0)
queue_python = Queue(r, queue='python')
@queue_python.handler
def handle(data):
name = data['name'] # job name
data = data['data'] # job data
print('TEST: ' + data['a'] + ' ' + data['b'] + ' ' + data['c'])
queue_python.listen()
- Sending jobs from Laravel :
<?php
$job = new \App\Jobs\TestJob('hi','send to','python');
dispatch($job)->onQueue('python');
- Отправка задачи в Laravel из Python / Schedule a job to be run in Laravel from Python:
from lara_queue import Queue
from redis import Redis
r = Redis(host='localhost', port=6379, db=0)
queue_laravel = Queue(r, queue='laravel')
queue_laravel.push('App\\Jobs\\TestJob', {'a': 'hello', 'b': 'send to', 'c': 'laravel'})
TestJob in Laravel:
<?php
namespace App\Jobs;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
class TestJob extends Job implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $a, $b, $c;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct ($a, $b, $c) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
}
public function handle () {
Log::info('TEST: ' . $this->a . ' '. $this->b . ' ' . $this->c);
}
}
- You need to :listen (or :work) the preferred queue name above to handle data sent from Python in Laravel.
php artisan queue:listen --queue=laravel
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 laraqueue-0.0.2.tar.gz.
File metadata
- Download URL: laraqueue-0.0.2.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7c468b1568d1859adf87292e95fb369d1c52fc50c6be806c2a0b6771b7ad474
|
|
| MD5 |
11ba0691b1723fd9445ae3ed8c2a452e
|
|
| BLAKE2b-256 |
0aad1bb53a9f8749dc3221fbe9c6e9fe0b58a2e4e41b48418a2c2f397726b9a6
|
File details
Details for the file laraqueue-0.0.2-py3-none-any.whl.
File metadata
- Download URL: laraqueue-0.0.2-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ff9e94288d543e984ece25acd1c5128eaa03a26a3a37be3ea7c571de39438bd
|
|
| MD5 |
3b4f24b96a358bb0c1dc60ceccaa979c
|
|
| BLAKE2b-256 |
021c726f7d8c828402d5f3e776d46aeed877f0aa9d8e0df95ff65a2245d37e2e
|