Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
488f943
commit af77b92
Showing
5 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
Binary file added
BIN
+18.3 KB
...(1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
description: BullMQ is now also available as an experimental python package. | ||
--- | ||
|
||
# Introduction | ||
|
||
{% hint style="info" %} | ||
The Python package is still in early development and is not recommended for production deployment just yet. In the following months, we will be hardening the code and adding more testing and we expect to have a production-ready package although not all the features are available as in the NodeJS version. | ||
{% endhint %} | ||
|
||
### Installation | ||
|
||
BullMQ is delivered as a pip package and can thus be installed using pip: | ||
|
||
``` | ||
$ pip install bullmq | ||
``` | ||
|
||
### Get started | ||
|
||
BullMQ uses [asyncio](https://docs.python.org/3/library/asyncio.html) in order to implement concurrency and provide efficient processing of jobs. | ||
|
||
You can add jobs to a queue like this, assuming you have a Redis host running locally: | ||
|
||
```python | ||
from bullmq import Queue | ||
|
||
queue = Queue("myQueue") | ||
|
||
# Add a job with data { "foo": "bar" } to the queue | ||
await queue.add("myJob", { "foo": "bar" }) | ||
|
||
... | ||
|
||
# Close when done adding jobs | ||
await queue.close() | ||
|
||
``` | ||
|
||
In order to consume the jobs from the queue you need to use the Worker class, providing a "processor" function that will consume the jobs. As soon as the worker is instantiated it will start consuming jobs: | ||
|
||
```python | ||
from bullmq import Worker | ||
|
||
async def process(job): | ||
# job.data will include the data added to the queue | ||
return doSomethingAsync(job) | ||
|
||
worker = Worker("myQueue", process) | ||
|
||
# When no need to process more jobs we should close the worker | ||
await worker.close() | ||
|
||
``` | ||
|