Documentation
The documentation is hosted at https://github.com/BingerYang/celery_context
Installation
pip install celery_context
Usage
example:
# -*- coding: utf-8 -*-
from flask import Flask
from celery_context import Celery
from flask import request
config = dict(redis={"host": "*****", "port": 31320, "password": "lab@2019"})
redis_url = "redis://:{password}@{host}:{port}".format(**config["redis"])
app = Flask("example.run")
app.config['CELERY_BROKER_URL'] = "{}/1".format(redis_url)
app.config['CELERY_RESULT_BACKEND'] = "{}/2".format(redis_url)
celery = Celery(app=app)
celery.setup_task_context(lambda: dict(path=request.path))
@celery.task(bind=True)
def add(self, a, b):
print("a+ n:", a + b, self.request.content)
return a + b
@app.route("/")
def index():
ret = add.delay(1, 3)
print(ret.get())
return ret.id
if __name__ == "__main__":
app.run()
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_context-0.0.2.20052710.tar.gz.
File metadata
- Download URL: celery_context-0.0.2.20052710.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9b020a0393dd0c4b6f09a1f0c1226499222f33f2dfee0aee0a758350c880191
|
|
| MD5 |
e51842f6fa4070366354c34e777fb073
|
|
| BLAKE2b-256 |
a14be24ce8a5c707487616ba0bdb30f0af269cb43bc636b347bb41763d8a8385
|
File details
Details for the file celery_context-0.0.2.20052710-py3-none-any.whl.
File metadata
- Download URL: celery_context-0.0.2.20052710-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7dfc0c62d384e32b8f610b33b96b4307f7eedee0e2e29cf8c0d15d62fac396f
|
|
| MD5 |
14a88211e59c852008139287a7310b26
|
|
| BLAKE2b-256 |
cd6fa9828b941bfda908d0877c77ff8ad2212b9cf3bfe478a420022af0c78839
|