python APScheduler调度出现 'Unable to determine the name of the local timezone -- you must explicitly '

问题描述:

Traceback (most recent call last):                                                                                                  
  File "./Premiumizer.py", line 1411, in <module>                                                                                   
    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")

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值