Skip to main content

celery_context

Documentation

The documentation is hosted at https://github.com/BingerYang/celery_context

Installation

adding the trace_id, task_name and task_id at celery log format

pip install celery_context

Usage

example:

# -*- coding: utf-8 -*-
from flask import Flask
from celery_context import Celery
from flask import request
from .. import celery_settings  # 存放celery 配置的文件
"""celery_settings
worker_log_format = '[%(trace_id)s%(task_name)s%(task_id)s%(process)s %(thread)s %(asctime)s %(pathname)s:%(lineno)s] %(levelname)s: %(message)s'
worker_task_log_format = worker_log_format
"""

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, broker=redis_url, backend=redis_url)
celery.config_from_object(celery_settings)
celery.add_flask_content(app)


@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()

Metadata

Release files for celery-context 0.0.3.23092222

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for celery-context 0.0.3.23092222
File Interpreter ABI Platform
celery_context-0.0.3.23092222-py2.py3-none-any.whl Python 2, Python 3 none any Details

Release files / celery_context-0.0.3.23092222-py2.py3-none-any.whl

Download URL celery_context-0.0.3.23092222-py2.py3-none-any.whl
Size 5.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
53c995055a3771956c20e1312e5c3ede8862d915e3d3cf220dc75f594443d1ac
BLAKE2b-256 checksum
How to use checksums
b0e6ae656a857a102aba340db2a89d90b51c84266f48183a943d73fc2ec33902
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Security for celery-context 0.0.3.23092222

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page