Skip to main content

Celery worker pool with support for asyncio coroutines as tasks

Project description

Celery AsyncIO Pool

python version downloads format

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

Using celery-aio-pool's Provided Patcher (non-preferred)

  • Import celery_aio_pool in the same module where your Celery "app" is defined
  • Ensure that the patch_celery_tracer utility 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,
)

Using (Upcoming) Out-Of-Tree Worker Pool (preferred)

At the time of writing, Celery does not have built-in support for out-of-tree pools like celery-aio-pool, but support should be included starting with the first non-beta release of Celery 5.3. (note: PR #7880 was merged on 2022-11-15).

The official release of Celery 5.3 enables the configuration of custom worker pool classes thusly:

  • Set the environment variable CELERY_CUSTOM_WORKER_POOL to the name of your desired worker pool implementation implementation.

    • NOTE: The value of the environment variable must be formatted in the standard Python/Celery format of package:class
    • % export CELERY_CUSTOM_WORKER_POOL='celery_aio_pool.pool:AsyncIOPool'
      
  • Tell Celery to use your desired pool by specifying --pool=custom when running your worker instance(s)

    • % celery worker --pool=custom --loglevel=INFO --logfile="$(pwd)/worker.log"
      

To verify the pool implementation, examine the output of the celery inspect stats command:

% celery --app=your_celery_project inspect stats
->  celery@freenas: OK
    {
        ...
        "pool": {
           ...
            "implementation": "celery_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

Optionally, if you do not have or 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

celery_aio_pool-0.1.0rc7.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

celery_aio_pool-0.1.0rc7-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file celery_aio_pool-0.1.0rc7.tar.gz.

File metadata

  • Download URL: celery_aio_pool-0.1.0rc7.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.2 Darwin/23.6.0

File hashes

Hashes for celery_aio_pool-0.1.0rc7.tar.gz
Algorithm Hash digest
SHA256 d6a93229a5e0eb337c97787f1faafeb48f3df136de944abca300547f497ded6e
MD5 4bfa2a6ba610061531e78e9bb0718c6a
BLAKE2b-256 80922eff07cff3aca2e381151889c0d3e8555d98d2915a81c9063398dd0a7953

See more details on using hashes here.

File details

Details for the file celery_aio_pool-0.1.0rc7-py3-none-any.whl.

File metadata

File hashes

Hashes for celery_aio_pool-0.1.0rc7-py3-none-any.whl
Algorithm Hash digest
SHA256 157c786c1e38f717345aae903866569c4b44cdecb24c912e2eadd029b9cd883c
MD5 515712d77a7d9c4f9fefadb2430dc005
BLAKE2b-256 c1ba8a7fc15089e14cca48f3a34aeec566d6ec618d35ef41fdff7770749a9f57

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page