APScheduler не выполняется должным образом - PullRequest
0 голосов
/ 16 апреля 2019

У меня есть несколько пользовательских модулей, которые вызываются из clock.py и работают apscheduler:

Проблема, вызванная 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)

То, что я ожидал, произойдет:

  • Чтобы вызвать apscheduler tweet_bss.py проверять канал Twitter каждый раз Запланированное задание запускается без сохранения чего-либо в памяти и обновляет страницу Google, если tweet_feed != google.sheets

Что происходит:

  • apscheduler проверяет твиттер только один раз, и если tweet_feed != google.sheets обновляет google.sheet как положено НО

Проблема

  • 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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Как заставить apscheduler выполнять tweet_bss.py, как предполагалось?

Спасибо!

...