APScheduler OCCASIONAL TypeError:无法腌制模块对象

时间:2018-11-27 10:48:52

标签: python python-3.x apscheduler

这是一个偶然的错误。我无法完全重现它。 APScheduler运行几个小时后,可能会发生。我更改了源代码(apscheduler / schedulers / base.py)以获得更多详细信息:

 989                         job_next_run = job.trigger.get_next_fire_time(run_times[-1], now)
 990                         if job_next_run:
 991                             job._modify(next_run_time=job_next_run)
 992                             try:
 993                                jobstore.update_job(job)
 994                             except Exception as ex:
 995                                print("update_job_error: ", job.__getstate__(), flush=True)
 996                                raise ex
 997                         else:
 998                             self.remove_job(job.id, jobstore_alias)

这是错误日志:

INFO:apscheduler.executors.default:Running job "Executor.execute (trigger: interval[0:00:30], next run at: 2018-11-25 13:08:01 CST)" (scheduled at 2018-11-25 13:07:31.070486+08:00)
update_job_error:  {'version': 1, 'id': '17@IdsAlarmCollecter', 'func': 'engine.core.executor.celery:Executor.execute', 'trigger': <IntervalTrigger (interval=datetime.timedelta(0, 30), start_date='2018-11-23 20
:55:31 CST', timezone='Asia/Shanghai')>, 'executor': 'default', 'args': (<engine.core.executor.celery.Executor object at 0x7f88b4b699e8>, 'IdsAlarmCollecter', 17), 'kwargs': {}, 'name': 'Executor.execute', 'mis
fire_grace_time': 1, 'coalesce': True, 'max_instances': 1, 'next_run_time': datetime.datetime(2018, 11, 25, 13, 8, 1, 75240, tzinfo=<DstTzInfo 'Asia/Shanghai' CST+8:00:00 STD>)}
INFO:apscheduler.executors.default:Running job "Executor.execute (trigger: interval[0:00:30], next run at: 2018-11-25 13:08:01 CST)" (scheduled at 2018-11-25 13:07:31.075240+08:00)
INFO:apscheduler.executors.default:Job "Executor.execute (trigger: interval[0:00:30], next run at: 2018-11-25 13:08:01 CST)" executed successfully
INFO:apscheduler.executors.default:Job "Executor.execute (trigger: interval[0:00:30], next run at: 2018-11-25 13:08:01 CST)" executed successfully
Exception in thread APScheduler:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/work/enginepy3env/lib/python3.6/site-packages/apscheduler/schedulers/blocking.py", line 30, in _main_loop
    wait_seconds = self._process_jobs()
  File "/opt/work/enginepy3env/lib/python3.6/site-packages/apscheduler/schedulers/base.py", line 996, in _process_jobs
    raise ex
  File "/opt/work/enginepy3env/lib/python3.6/site-packages/apscheduler/schedulers/base.py", line 993, in _process_jobs
    jobstore.update_job(job)
  File "/opt/work/enginepy3env/lib/python3.6/site-packages/apscheduler/jobstores/sqlalchemy.py", line 106, in update_job
    'job_state': pickle.dumps(job.__getstate__(), self.pickle_protocol)
TypeError: can't pickle module objects

它说job.__getstate__()不能是酱菜堆。但是我在apscheduler / schedulers / base.py:995中打印的最后一个job.__getstate__()确实可以是转储。而且有时调度程序会死掉而没有任何错误,我无法识别出BackgroundThread消失了或Loop死锁了。

更令人困惑的是,相同的代码可以在另一台机器上很好地运行。

0 个答案:

没有答案