我正在运行一个celery任务,它需要两个参数,如下所示:
@task_bp.route('/analysis/<user_id>', methods=['GET', 'POST'])
def save_user_with_analysis(user_id):
post_data = request.get_json()
response_object = {
'status': 'fail',
'message': 'User does not exist'
}
spotify_token = ''
if post_data:
spotify_token = post_data.get('spotify_token')
try:
user = User.query.filter_by(id=user_id).first()
if not user:
return jsonify(response_object), 404
else:
# pass 2 args, ID and token
task = save_user_tracks_with_analysis.apply_async(args=[user_id, spotify_token],kwargs={})
response_object = {
'status': 'success',
'message': 'Background task for saving user analysis to database initialized.',
'data': {
'task_id': task.id,
}
}
return jsonify(response_object), 202
except (exc.IntegrityError, ValueError):
db.session.rollback()
return jsonify(response_object), 404
和:
@celery.task(queue='analysis',default_retry_delay=30,max_retries=3,soft_time_limit=1000)
def save_user_tracks_with_analysis(user_id, spotify_token):
track_and_features = sp_utilities.query_tracks(spotify_token)
try:
while True:
result = Upload_Track_With_Audio_Analysis(dataset=next(track_and_features),
user_id=user_id)
except StopIteration:
pass
finally:
del track_and_features
return {'Status': 'Tracks uploaded with analysis!'}
[2019-10-23 00:38:58,444: INFO/MainProcess] Received task: project.api.routes.background.save_user_tracks_with_analysis[d0db40ee-a1bb-4dbb-b066-7db9b5f5900d]
[2019-10-23 00:38:58,450: DEBUG/MainProcess] TaskPool: Apply <function _fast_trace_task at 0x7f5d8a9448c8> (args:('project.api.routes.background.save_user_tracks_with_analysis', 'd0db40ee-a1bb-4dbb-b066-7db9b5f5900d', {'lang': 'py', 'task': 'brandio.api.routes.background.save_user_tracks_with_analysis', 'id': 'd0db40ee-a1bb-4dbb-b066-7db9b5f5900d', 'shadow': None, 'eta': None, 'expires': None, 'group': None, 'retries': 0, 'timelimit': [None, 1000], 'root_id': 'd0db40ee-a1bb-4dbb-b066-7db9b5f5900d', 'parent_id': None, 'argsrepr': "['1', '']", 'kwargsrepr': '{}', 'origin': 'gen14@9065a884289a', 'reply_to': '4ed9cf27-826d-3d3d-9282-83750953189b', 'correlation_id': 'd0db40ee-a1bb-4dbb-b066-7db9b5f5900d', 'delivery_info': {'exchange': '', 'routing_key': 'analysis', 'priority': 0, 'redelivered': None}}, b'[["1", ""], {}, {"callbacks": null, "errbacks": null, "chain": null, "chord": null}]', 'application/json', 'utf-8') kwargs:{})
[2019-10-23 00:38:58,457: DEBUG/MainProcess] Task accepted: project.api.routes.background.save_user_tracks_with_analysis[d0db40ee-a1bb-4dbb-b066-7db9b5f5900d] pid:12
[2019-10-23 00:38:58,456: ERROR/ForkPoolWorker-3] Task project.api.routes.background.save_user_tracks_with_analysis[d0db40ee-a1bb-4dbb-b066-7db9b5f5900d] raised unexpected: TypeError('save_user_tracks_with_analysis() takes 1 positional argument but 2 were given',)
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/celery/app/trace.py", line 382, in trace_task
R = retval = fun(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/celery/app/trace.py", line 641, in __protected_call__
return self.run(*args, **kwargs)
TypeError: save_user_tracks_with_analysis() takes 1 positional argument but 2 were given
[2019-10-23 00:40:10,528: INFO/MainProcess] Received task: project.api.routes.background.save_user_tracks_with_analysis[a049f85f-bb5a-4cf3-81f8-f334210cb7e4]
[2019-10-23 00:40:10,532: DEBUG/MainProcess] TaskPool: Apply <function _fast_trace_task at 0x7f5d8a9448c8> (args:('project.api.routes.background.save_user_tracks_with_analysis', 'a049f85f-bb5a-4cf3-81f8-f334210cb7e4', {'lang': 'py', 'task': 'project.api.routes.background.save_user_tracks_with_analysis', 'id': 'a049f85f-bb5a-4cf3-81f8-f334210cb7e4', 'shadow': None, 'eta': None, 'expires': None, 'group': None, 'retries': 0, 'timelimit': [None, 1000], 'root_id': 'a049f85f-bb5a-4cf3-81f8-f334210cb7e4', 'parent_id': None, 'argsrepr': "['1', 'BQCFoIPB1BS3_Fe4nrHuTJMJ2bDDqOJBlEMH2-TwzrAeLk8GN30O3DQm3hRW2DRFVbaDb-0msctmjN6phKAmad4F6hs9AilCyyO_Ky5JoT1cThsRNoL6GptRh1SPcYL29toTkUQitXcRSaDRQY0BsJB9haNtCRD-KNhNPQSC0dbCB6M-tWBd-4l9hl74tRR7csamu5qBol653QBfoNhcKzvJeSaewPMpyhMArvA_DW4Pcr8KLFsFmEV8jiDb2d0f']", 'kwargsrepr': '{}', 'origin': 'gen14@9065a884289a', 'reply_to': '4ed9cf27-826d-3d3d-9282-83750953189b', 'correlation_id': 'a049f85f-bb5a-4cf3-81f8-f334210cb7e4', 'delivery_info': {'exchange': '', 'routing_key': 'analysis', 'priority': 0, 'redelivered': None}}, b'[["1",... kwargs:{})
[2019-10-23 00:40:10,536: DEBUG/MainProcess] Task accepted: project.api.routes.background.save_user_tracks_with_analysis[a049f85f-bb5a-4cf3-81f8-f334210cb7e4] pid:13
[2019-10-23 00:40:10,537: ERROR/ForkPoolWorker-4] Task project.api.routes.background.save_user_tracks_with_analysis[a049f85f-bb5a-4cf3-81f8-f334210cb7e4] raised unexpected: TypeError('save_user_tracks_with_analysis() takes 1 positional argument but 2 were given',)
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/celery/app/trace.py", line 382, in trace_task
R = retval = fun(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/celery/app/trace.py", line 641, in __protected_call__
return self.run(*args, **kwargs)
TypeError: save_user_tracks_with_analysis() takes 1 positional argument but 2 were given
[2019-10-23 01:45:54,209: INFO/MainProcess] Received task: project.api.routes.background.save_user_tracks_with_analysis[7391e3c7-ddf9-4f76-a046-36506b3c8289]
[2019-10-23 01:45:54,212: DEBUG/MainProcess] TaskPool: Apply <function _fast_trace_task at 0x7f5d8a9448c8> (args:('project.api.routes.background.save_user_tracks_with_analysis', '7391e3c7-ddf9-4f76-a046-36506b3c8289', {'lang': 'py', 'task': 'project.api.routes.background.save_user_tracks_with_analysis', 'id': '7391e3c7-ddf9-4f76-a046-36506b3c8289', 'shadow': None, 'eta': None, 'expires': None, 'group': None, 'retries': 0, 'timelimit': [None, 1000], 'root_id': '7391e3c7-ddf9-4f76-a046-36506b3c8289', 'parent_id': None, 'argsrepr': "('1', 'BQABvl5STugFWzHizIipkw0B7-_g7MmP-lFAokVh4_XMJFHGl6XYNmEvi8AieQduMxpqHCujjkOJC4sypY4w-7_77NSsspXUpVn65bW77VeyihG5JLmJpIC86pqzzijZZTZfu-RTt1_yBCkK7UXsEb1K7biWcL8gpVsfZu1vAsFsI1V51IP3sxKoXf3ohPxTLddH1Wfi_npfOv1wkgaeLdbwxCaO2gEqowqRappzIiSNfXqCSAIdNNaGPROqpR5r')", 'kwargsrepr': '{}', 'origin': 'gen30@9065a884289a', 'reply_to': '5b96d61f-e2f9-3237-a7a1-afab83d41e12', 'correlation_id': '7391e3c7-ddf9-4f76-a046-36506b3c8289', 'delivery_info': {'exchange': '', 'routing_key': 'analysis', 'priority': 0, 'redelivered': None}}, b'[["1",... kwargs:{})
[2019-10-23 01:45:54,214: DEBUG/MainProcess] Task accepted: project.api.routes.background.save_user_tracks_with_analysis[7391e3c7-ddf9-4f76-a046-36506b3c8289] pid:12
[2019-10-23 01:45:54,225: ERROR/ForkPoolWorker-3] Task project.api.routes.background.save_user_tracks_with_analysis[7391e3c7-ddf9-4f76-a046-36506b3c8289] raised unexpected: TypeError('save_user_tracks_with_analysis() takes 1 positional argument but 2 were given',)
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/celery/app/trace.py", line 382, in trace_task
R = retval = fun(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/celery/app/trace.py", line 641, in __protected_call__
return self.run(*args, **kwargs)
TypeError: save_user_tracks_with_analysis() takes 1 positional argument but 2 were given
我不明白为什么,但当我重新启动Docker应用程序,和所有芹菜工人,上面的代码开始工作。
问题内容: 我正在用Tk用python创建Sudoku游戏。 我在按键上的按钮功能上遇到错误 和这个错误/例外 我不在乎错误在哪里。我已经将自我纳入了我的职能 问题答案: 我看到已经回答了这个问题,但是我有一种我真的更喜欢的方式,并且您和其他人会很感激。 假设您的方法kk用于多个位置,并且您不想发送任何随机变量来占据下面显示的“ another_parameter”的位置(根据Christian的
在我的程序中,我主要想返回一个方法的结果,该方法测试两个学生之间的相等性(即,如果两个学生上的课的数量相等) 我创建了一个名为Student的类。然后我创建了两个函数并定义了它们的属性。实际上,我试图比较student类中的两个对象,而一个方法需要检查这两个对象之间的相等性。
Tkinter回调跟踪中的异常(最近的调用是最后一次): 文件“C:...\programs\python\python37\lib\tkinter__init__.py”,第1705行,在调用返回self.func(*args)typeError:done()接受1个位置参数,但给出了2个 有谁知道我犯了什么错误,能给我一个例子,如何使它更好和改进吗?
...为什么Python告诉我我给了它两个参数,而我只给了一个?
问题内容: 如果我有课… 我这样称呼 …为什么当我只给出一个参数时,Python告诉我给它两个参数? 问题答案: 在Python中,这是: …是语法糖,口译员在后台将其翻译为: …,如你所见,它确实有两个参数-从调用者的角度来看,只是第一个参数是隐式的。 这是因为大多数方法会对被调用的对象进行某些处理,因此需要某种方法在该方法内部引用该对象。按照惯例,第一个参数self在方法定义内调用: 如果你呼