APScheduler无法按预期执行

时间:2019-04-16 00:04:55

标签: python apscheduler

我有几个自定义模块,它们是通过运行apscheduler的clock.py调用的:

APScheduler引起的问题

apscheduler会按计划的间隔不断重复插入相同的日期,这时应该首先检查Twitter提要,然后如果与Google表格不同,则不进行任何操作。

模块

  1. clock.py:
    1. 实例化BlockingScheduler()
    2. 安排工作
    3. .start()工作
  2. 模块tweet_bss.py:
    1. 检查一条推文提要:
      1. 将当前供稿值与Google表格中保存的值进行比较。
    2. If的值不同:
      1. 为Google表格添加新的价值
      2. 更新本地状态文件
  3. 模块dev_smtplib.py:
    1. 检查状态文件
      1. 如果状态为True,则发送电子邮件更新
  

当前问题出在 clock.py和模块a

clock.py

sched = BlockingScheduler()
sched.add_job(tweet_bss.main, 'interval', seconds = 120)
sched.print_jobs()
sched.start()

模块tweet_bss.main()

def main():
    """
    This script will import the sheets module, open a connection to twitter
    pass account name and numb of tweets open a connection with sheets,
    if last row 'text' from 'sheets' != 'tweet text' and 'is not None'
    then it will enter the exchange into the spread sheet
    """
    last_row = sheets.row_count()
    last_entry = sheets.get_text(last_row)
    last_entry = str(last_entry)
    for tweet in tweets('tweet_account', 1):
        if last_entry != bss_extract(tweet.text) is not None:
            sheets.bss_insert([str(tweet.created_at), tweet.lang,
                               tweet.source_url, float(bss_extract(tweet.text))])
            pickler([str(tweet.created_at), float(bss_extract(tweet.text))])
            sc.bss_update(True)
            print(f'from tweet_bss.py for {TODAY} @ {TIME}')
            print(f'if {last_entry} != {bss_extract(tweet.text)} is not None')
            print(f'a. Twitter data inserted on {tweet.created_at} to sheets')
            print('b. pickler() function updated the pickle file with date and exchange rate to be used for email')
            print('c. The status.yaml was updated to True, letting the SMTP script know "update" can be emailed')
            print('~' * 45)
        else:
            print(f'from tweet_bss.py for {TODAY} @ {TIME}')
            print(f'No update needed:')
            print(f'\tSheets last entry {last_entry} == {bss_extract(tweet.text)} (current tweet exchange) and is not None')
            print('\t\t* The email pickle was not updated with exchange rate and date')
            print('\t\t* The status was not updated to True')
            print('~' * 45)

我期望发生的事情:

  • 要安排一次呼叫,请 tweet_bss.py 每次运行时查看Twitter提要,而不要将任何现金存入内存并在{{1} }

正在发生的事情:

  • tweet_feed != google.sheets仅检查一次Twitter feed,并且如果apscheduler是否按预期更新google.sheet

问题

  • tweet_feed != google.sheets会按计划的时间间隔不断插入相同的日期,这是每次应检查Twitter feed的时候。
apscheduler

如何使apscheduler按预期执行""" print statements I wrote for particular conditions in Module A """ Pending jobs: main (trigger: interval[0:02:00], pending) from tweet_bss.py for 2019-04-15 @ 15:12:09 if 5009.63 != 5015.26 is not None Twitter data inserted on 2019-04-15 19:07:19 to sheets pickler() function updated the pickle file with date and exchange rate to be used for email the status.yaml was updated to True, letting the SMTP script know it can be email ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ from tweet_bss.py for 2019-04-15 @ 15:12:09 if 5009.63 != 5015.26 is not None Twitter data inserted on 2019-04-15 19:07:19 to sheets pickler() function updated the pickle file with date and exchange rate to be used for email the status.yaml was updated to True, letting the SMTP script know it can be email ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ from tweet_bss.py for 2019-04-15 @ 15:12:09 if 5009.63 != 5015.26 is not None Twitter data inserted on 2019-04-15 19:07:19 to sheets pickler() function updated the pickle file with date and exchange rate to be used for email the status.yaml was updated to True, letting the SMTP script know it can be email ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ from tweet_bss.py for 2019-04-15 @ 15:12:09 if 5009.63 != 5015.26 is not None Twitter data inserted on 2019-04-15 19:07:19 to sheets pickler() function updated the pickle file with date and exchange rate to be used for email the status.yaml was updated to True, letting the SMTP script know it can be email ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

谢谢!

0 个答案:

没有答案