这可能是一个明显的船长风格的问题,但我觉得我错过了一些东西。
我继承了一个创建 Celery 任务的 Python WSGI 应用程序。看起来像这样:
#web.py
from bottle import route, run, request, response, abort
import bottle
from project.tasks import process_request
@route('/')
def web():
url = request.query_string
process_request.delay(
url=url,
path=request.path,
query=request.query_string,
cookies=dict(request.cookies),
headers=dict(request.headers),
remote_addr=request.remote_addr,
)
该process_request
方法如下所示:
#tasks.py
@celery.task
def process_request(url, path, query, cookies, headers, remote_addr):
#does some stuff
以上所有工作。我尝试向 process_request 添加时间戳,因此调用如下所示:
#web.py
#imports from above
from datetime import datetime
@route('/')
def web():
url = request.query_string
process_request.delay(
url=url,
path=request.path,
query=request.query_string,
cookies=dict(request.cookies),
headers=dict(request.headers),
remote_addr=request.remote_addr,
s_time=str(datetime.now())
)
我将process_request
方法更改为:
#tasks.py
@celery.task
def process_request(url, path, query, cookies, headers, remote_addr, s_time):
#does some stuff
那没有用。未处理请求。我检查了我的 celeryd 日志文件,发现了这个:
[2013-03-26 16:19:03,330: ERROR/MainProcess] Task beacon.tasks.process_request[235f9fa8-1f10-4ee0-a1f9-e389021ea0ad] raised exception: TypeError('process_request() takes exactly 7 non-keyword arguments (6 given)',)
Traceback (most recent call last):
File "/home/beacon/.virtualenvs/beacon/lib/python2.6/site-packages/celery/task/trace.py", line 228, in trace_task
R = retval = fun(*args, **kwargs)
File "/home/beacon/.virtualenvs/beacon/lib/python2.6/site-packages/celery/task/trace.py", line 415, in __protected_call__
return self.run(*args, **kwargs)
TypeError: process_request() takes exactly 7 non-keyword arguments (6 given)
我不知道我做错了什么。有人有想法么?