A
,其数组订阅了redis
订户连续获取数据并应在内部运行
一个线程。 A
我如何在Celery中做到这一点?任何方向将不胜感激。
class A(object):
def __init__(self):
self.items = []
def on_subscribe(new_item):
self.items.append(new_item)
insert_data.delay(1544500000)
# ???? how do I update the items array here from task results
def update_items_from_task():
pass
# Configure with your own broker
app = Celery("tasks", broker="redis://localhost:6379")
@app.task
def insert_data(timestamp):
return requests.get(API_URL + '/' + timestsamp)
@task_success.connect
def on_task_complete(sender=None, result=None, **kwargs):
print("task successful", result)