Celery worker pool with support for asyncio coroutines as tasks
Project description
Celery AsyncIO Pool
Free software: GNU Affero General Public License v3+
Getting Started
Installation
Using Poetry (preferred)
poetry add celery-aio-pool
Using pip & PyPI.org
pip install celery-aio-pool
Using pip & GitHub
pip install git+https://github.com/the-wondersmith/celery-aio-pool.git
Using pip & A Local Copy Of The Repo
git clone https://github.com/the-wondersmith/celery-aio-pool.git
cd celery-aio-pool
pip install -e "$(pwd)"
Configure Celery
Option 1: Using Celery's Out-Of-Tree Worker Pool (preferred)
Configuring Custom Worker Pool
Celery now supports the configuration of out-of-tree worker pool classes, allowing you to configure custom pools like celery-aio-pool directly:
-
Set the environment variable
CELERY_CUSTOM_WORKER_POOLto the name of your desired worker pool implementation.- NOTE: The value must be formatted as
package:class -
export CELERY_CUSTOM_WORKER_POOL='celery_aio_pool.pool:AsyncIOPool'
- NOTE: The value must be formatted as
-
Start Celery with
--pool=customto use the configured pool:-
celery worker --pool=custom --loglevel=INFO --logfile="$(pwd)/worker.log"
-
To verify the pool configuration, use celery inspect stats:
celery --app=your_celery_project inspect stats
-> celery@freenas: OK
{
...
"pool": {
...
"implementation": "celery_aio_pool.pool:AsyncIOPool",
...
Option 2: Monkey-patching Celery (non-preferred) for older versions of Celery (<5.3)
Using celery-aio-pool's Provided Patcher
- Import
celery_aio_poolin the same module where your Celery "app" is defined - Ensure that the
patch_celery_tracerutility is called before any other Celery code is called
"""My super awesome Celery app."""
# ...
from celery import Celery
# add the following import
import celery_aio_pool as aio_pool
# ensure the patcher is called *before*
# your Celery app is defined
assert aio_pool.patch_celery_tracer() is True
app = Celery(
"my-super-awesome-celery-app",
broker="amqp://guest@localhost//",
# add the following keyword argument
worker_pool=aio_pool.pool.AsyncIOPool,
)
Developing / Testing / Contributing
NOTE: Our preferred packaging and dependency manager is Poetry. Installation instructions can be found here.
Developing
Clone the repo and install the dependencies
$ git clone https://github.com/the-wondersmith/celery-aio-pool.git \
&& cd celery-aio-pool \
&& poetry install --sync
Alternatively, if you prefer not to use Poetry, celery-aio-pool is fully PEP-517
compliant and can be installed directly by any PEP-517-compliant package manager.
$ cd celery-aio-pool \
&& pip install -e "$(pwd)"
TODO: Coming Soon™
Testing
To run the test suite:
$ poetry run pytest tests/
Contributing
TODO: Coming Soon™
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 celery_aio_pool-0.1.0rc8.tar.gz.
File metadata
- Download URL: celery_aio_pool-0.1.0rc8.tar.gz
- Upload date:
- Size: 24.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.12.2 Darwin/23.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47ffe9307a8be94eb39cc1c6607f49b18db2c797623fb6ea0825835dd50652f2
|
|
| MD5 |
12df129c8e3d12b749c77b0575771a40
|
|
| BLAKE2b-256 |
24502d0962983fe1b21a4969454f804c12b5d10ad5ae335342b8520eed1d8899
|
File details
Details for the file celery_aio_pool-0.1.0rc8-py3-none-any.whl.
File metadata
- Download URL: celery_aio_pool-0.1.0rc8-py3-none-any.whl
- Upload date:
- Size: 23.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.12.2 Darwin/23.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a7631ea2759e6c8ae769fe668a3af34299a6ee730dabe57e36e66d66611b14a
|
|
| MD5 |
22c8a36c9c9e4dc6a6ddc72c343fd10a
|
|
| BLAKE2b-256 |
3fed27407bd7aa280c9d6a3a33d541277bc35ad9a97d2eabac3c67e148da29fb
|