python中的棚架任务中的位置参数错误
当我尝试运行代码时,我遇到了一个位置参数错误,并且do()将额外的参数传递给工作函数,
import schedule
from schedule import Scheduler
import threading
import warnings
import time
def paystack_webhookS (request):
user = request.user
remail = payload.customer.email
rfirst_name = payload.customer.first_name
amount = payload.data.amount
first_name = user.first_name
last_name = user.last_name
email = user.email
with transaction.atomic():
account = Account.objects.select_for_update().get(email = remail)
account.balance += amount
asof = account.modified
account.save(update_fields=[
'balance',
'modified',
])
return HttpResponse(status=200)
schedule.every(10).seconds.do(paystack_webhookS)
schedule.every(10).minutes.do(paystack_webhookS)
schedule.every().hour.do(paystack_webhookS)
while True:
schedule.run_pending()
time.sleep(1)
我收到了此错误,
schedule.run_pending()
return view_func(*args, **kwargs)
TypeError: inner() missing 1 required positional argument: 'request'
此错误在尝试执行时会遇到此错误
while True:
schedule.run_pending()
time.sleep(1)
I got a positional argument error when i tried running my code and the do() passes extra arguments to the job function
import schedule
from schedule import Scheduler
import threading
import warnings
import time
def paystack_webhookS (request):
user = request.user
remail = payload.customer.email
rfirst_name = payload.customer.first_name
amount = payload.data.amount
first_name = user.first_name
last_name = user.last_name
email = user.email
with transaction.atomic():
account = Account.objects.select_for_update().get(email = remail)
account.balance += amount
asof = account.modified
account.save(update_fields=[
'balance',
'modified',
])
return HttpResponse(status=200)
schedule.every(10).seconds.do(paystack_webhookS)
schedule.every(10).minutes.do(paystack_webhookS)
schedule.every().hour.do(paystack_webhookS)
while True:
schedule.run_pending()
time.sleep(1)
i got this error
schedule.run_pending()
return view_func(*args, **kwargs)
TypeError: inner() missing 1 required positional argument: 'request'
this error is gotten when trying to execute
while True:
schedule.run_pending()
time.sleep(1)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将传递给时间表的功能(您将其命名为“ Paystack_webhooks”)必须在没有任何参数的情况下定义。
您的代码不会告诉“请求”变量来自何处。但是,如果它不是全局,而是在初始化时间表任务时已经定义了,则可以使用包装函数来创建实际的时间表函数:
然后:
The function you pass to the schedule (you named it "paystack_webhookS") must be defined without any arguments.
Your code doesn't tell where the "request" variable is coming from. But if it is not global but already defined when the schedule tasks are initialized, you could work with a wrapper function creating your actual schedule function:
And then: