APScheduler ValueError:目标可调用对象不接受以下关键字参数:

时间:2017-09-25 16:35:17

标签: python python-3.x apscheduler

我遇到一个错误,在函数中使用kwargs调用add_job:

我创建了一个创建预定作业的功能:

def initial_data_pull():
    q.enqueue(initial_pull, timout='3h')


def initial_data_load():
    dates_list = date_between_list(start=date(2010, 1, 1), stop=date.today())
    naics = ['541611', '541618', '541613',
             '541511', '541512', '541513',
             '541519', '518210', '541612']
    fundings = ['3600', '97DH', '7504', '7505',
                '7522', '7523', '7524', '7526',
                '7527', '7528', '7529', '7530',
                '7570']
    for date_item in dates_list:
        for fund in fundings:
            for naic in naics:
                sched.add_job(initial_data_pull,
                              kwargs={'naics_code': naic,
                                      'funding_agency_id': fund,
                                      'date_signed': date_item})

函数initial_pull看起来像:

def initial_pull(naics_code=None, funding_agency_id=None, date_signed=None):
    print('Gathering Contracts...')
    df = fpds_generic(naics_code=naics_code,
                      funding_agency_id=funding_agency_id,
                      date_signed=date_signed)
    # Code to Process and load data

函数fpds_generic是一个转换为fpds和收集数据的函数。运行inital_data_load函数时出现以下错误。

Traceback (most recent call last):
  File "clock.py", line 55, in <module>
    initial_data_load()
  File "clock.py", line 52, in initial_data_load
    sched.add_job(initil_data_pull, kwargs=kw)
  File "/home/spitfiredd/anaconda3/envs/g2x_flask/lib/python3.6/site-packages/apscheduler/schedulers/base.py", line 425, in add_job
    job = Job(self, **job_kwargs)
  File "/home/spitfiredd/anaconda3/envs/g2x_flask/lib/python3.6/site-packages/apscheduler/job.py", line 44, in __init__
    self._modify(id=id or uuid4().hex, **kwargs)
  File "/home/spitfiredd/anaconda3/envs/g2x_flask/lib/python3.6/site-packages/apscheduler/job.py", line 175, in _modify
    check_callable_args(func, args, kwargs)
  File "/home/spitfiredd/anaconda3/envs/g2x_flask/lib/python3.6/site-packages/apscheduler/util.py", line 385, in check_callable_args
    ', '.join(unmatched_kwargs))
ValueError: The target callable does not accept the following keyword arguments: naics_code, funding_agency_id, date_signed

为什么说该函数不接受这些关键字args,我该如何解决?

0 个答案:

没有答案