Skip to content

Commit

Permalink
对模块进行改名优化
Browse files Browse the repository at this point in the history
  • Loading branch information
binger.yang committed May 27, 2020
1 parent 013482c commit 591a647
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# flask_celery_context
# celery_context

## Documentation
The documentation is hosted at [https://github.com/BingerYang/logger_app](https://github.com/BingerYang/flask_celery_context)
The documentation is hosted at [https://github.com/BingerYang/celery_context](https://github.com/BingerYang/celery_context)

## Installation
```shell
Expand All @@ -12,15 +12,15 @@ The documentation is hosted at [https://github.com/BingerYang/logger_app](https:
```python
# -*- coding: utf-8 -*-
from flask import Flask
from flask_celery import Celery
from celery_context import Celery
from flask import request

config = dict(redis={"host": "*****", "port": 31320, "password": "lab@2019"})
redis_url = "redis:https://:{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)
celery = Celery(app=app)
celery.setup_task_context(lambda: dict(path=request.path))


Expand All @@ -40,4 +40,4 @@ def index():
if __name__ == "__main__":
app.run()

```
```
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
flask_celery_context
====================
celery_context
==============

Documentation
-------------

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


Installation
------------

.. code:: shell
pip install flask_celery_context
pip install celery_context
Usage
-----
Expand All @@ -24,15 +24,15 @@ example:

# -*- coding: utf-8 -*-
from flask import Flask
from flask_celery import Celery
from celery_context import Celery
from flask import request

config = dict(redis={"host": "*****", "port": 31320, "password": "lab@2019"})
redis_url = "redis:https://:{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)
celery = Celery(app=app)
celery.setup_task_context(lambda: dict(path=request.path))


Expand Down
6 changes: 3 additions & 3 deletions flask_celery/__init__.py → celery_context/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# @Time : 2020-02-07 11:26
# @Author : binger

name = "flask_celery_context"
version_info = (0, 0, 1, 20040717)
name = "celery_context"
version_info = (0, 0, 2, 20052710)
__version__ = ".".join([str(v) for v in version_info])
__description__ = '实现celery在flask下的上下文一致性的简单扩展'
__description__ = '实现celery在flask/django下的上下文一致性的简单扩展'

from .model import Celery, reload_celery_task
4 changes: 3 additions & 1 deletion flask_celery/model.py → celery_context/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# @Author : binger

__all__ = ["reload_celery_task", "Celery"]

from celery import Celery as CeleryBase

# 在异步处理时使用,如下:
Expand Down Expand Up @@ -69,8 +70,9 @@ def retry(self, args=None, kwargs=None, task_id=None, **rest):
class Celery(CeleryBase):
_setup_task_context_cb = None

def __init__(self, app=None, *args, **kwargs):
def __init__(self, *args, **kwargs):
super(Celery, self).__init__(*args, **kwargs)
app = kwargs.get("app", None)
if app:
self.init_app(app)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from setuptools import setup, find_packages
from flask_celery import name, __description__, __version__
from celery_context import name, __description__, __version__

# read dev requirements
fname = os.path.join(os.path.dirname(__file__), 'requirements.txt')
Expand Down

0 comments on commit 591a647

Please sign in to comment.