Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sinanbekar/python-laravel-queue
Sync Laravel queue with Python. Provides an interface for communication between Laravel and Python.
https://github.com/sinanbekar/python-laravel-queue
laravel laravel-queue python python-queue queue redis
Last synced: 3 months ago
JSON representation
Sync Laravel queue with Python. Provides an interface for communication between Laravel and Python.
- Host: GitHub
- URL: https://github.com/sinanbekar/python-laravel-queue
- Owner: sinanbekar
- License: mit
- Created: 2022-01-12T09:38:59.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-12T12:13:25.000Z (about 3 years ago)
- Last Synced: 2024-09-08T05:59:54.480Z (4 months ago)
- Topics: laravel, laravel-queue, python, python-queue, queue, redis
- Language: Python
- Homepage: https://pypi.org/project/python-laravel-queue/
- Size: 8.79 KB
- Stars: 7
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Python Laravel Queue
Queue sync between Python and Laravel using Redis driver. You can process jobs dispatched from Laravel in Python.
**NOTE: This package is in beta and only Redis is supported currently. Production usage is not recommended until stable release.**
In the 1.0.0 stable version these implementations are planned:
- Auto-discovery jobs in both Laravel and Python.
- Auto-configuration by reading Laravel config in Python side.
- More clean API.
- Supporting more queue drivers.### Install
```bash
pip install python-laravel-queue
```### Usage
- Listen for jobs on Python:
```python
from python_laravel_queue import Queue as PlQueue
from redis import Redisr = Redis(host='localhost', port=6379, db=0)
queue_python = PlQueue(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
onQueue('python');
```- Schedule a job to be run in Laravel from Python:
```python
from python_laravel_queue import Queue as PlQueue
from redis import Redisr = Redis(host='localhost', port=6379, db=0)
queue_laravel = PlQueue(r, queue='laravel')
queue_laravel.push('App\\Jobs\\TestJob', {'a': 'hello', 'b': 'send to', 'c': 'laravel'})```
**TestJob** in Laravel:
```php
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.
```bash
php artisan queue:listen --queue=laravel
```