问题描述:
Traceback (most recent call last):
File "./Premiumizer.py", line 1411, in
seconds=active_interval, replace_existing=True, max_instances=1, coalesce=True)
File "/virtualenv/lib/python2.7/site-packages/apscheduler/schedulers/base.py", line 366, in add_job
'trigger': self._create_trigger(trigger, trigger_args),
File "/virtualenv/lib/python2.7/site-packages/apscheduler/schedulers/base.py", line 848, in _create_trigger
return self._create_plugin_instance('trigger', trigger, trigger_args)
File "/virtualenv/lib/python2.7/site-packages/apscheduler/schedulers/base.py", line 833, in _create_plugin_instance
return plugin_cls(**constructor_kwargs)
File "/virtualenv/lib/python2.7/site-packages/apscheduler/triggers/interval.py", line 37, in __init__
self.timezone = astimezone(timezone)
File "/virtualenv/lib/python2.7/site-packages/apscheduler/util.py", line 77, in astimezone
'Unable to determine the name of the local timezone -- you must explicitly '
ValueError: Unable to determine the name of the local timezone -- you must explicitly specify the name of the local timezone. Please
refrain from using timezones like EST to prevent problems with daylight saving time. Instead, use a locale based timezone name (suc
h as Europe/Helsinki).`
简述:
APScheduler提供了多种调度器,可以根据具体需求来选择合适的调度器,常用的调度器有:
BlockingScheduler:适合于只在进程中运行单个任务的情况,通常在调度器是你唯一要运行的东西时使用。
BackgroundScheduler: 适合于要求任何在程序后台运行的情况,当希望调度器在应用后台执行时使用。
AsyncIOScheduler:适合于使用asyncio框架的情况
GeventScheduler: 适合于使用gevent框架的情况
TornadoScheduler: 适合于使用Tornado框架的应用
TwistedScheduler: 适合使用Twisted框架的应用
QtScheduler: 适合使用QT的情况
class Schedule(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.schedule = BlockingScheduler() self.type = SCHEDULE_ENUM.CRON self.job_name = None self.is_run = False self.is_first_start = False self.func_job_schedule = None self.create_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") self.run_count = 0 self.update_time = None self.params = None self.job_id = 'my_job_id'
只需要将加黑的部分做修改即可:
sched = BlockingScheduler(timezone="UTC")