コード例 #1
0
def scheduled_task(chat_id, notification_datetime, city):
    bot.bot.send_message(chat_id, weather.get_weather_report(city, 0))
    scheduler.add_job(func=scheduled_task,
                      trigger='date',
                      run_date=notification_datetime,
                      args=[chat_id, notification_datetime, city],
                      id=chat_id)
    scheduler.start()
コード例 #2
0
ファイル: routes.py プロジェクト: epikt/cl-concerts-db
def initialize_cache():
    from config import Config
    from app.api.events_cache import refresh_cache_thread, refresh_cache
    from app import scheduler, current_app

    # we'll set the run interval just little less than the CACHE TIMEOUT to avoid
    # the refresh be > CACHE_TIMEOUT
    logger.debug("initializing cache")
    refresh_cache(True)
    logger.debug("starting refresh thread")
    scheduler.add_job(refresh_cache_thread,
                      'interval',
                      seconds=Config.CACHE_TIMEOUT - 10,
                      args=[current_app._get_current_object()])
    scheduler.start()
コード例 #3
0
def run_tasks():
    chat_id = str(request.args.get("chat_id"))
    hours = int(request.args.get("hours"))
    minutes = int(request.args.get("minutes"))
    city = request.args.get("city")

    local = pytz.timezone("Europe/Kiev")
    now = datetime.now(local)
    notification_datetime = now.replace(hour=int(hours),
                                        minute=int(minutes),
                                        second=0)
    if now > notification_datetime:
        notification_datetime = notification_datetime.replace(day=now.day + 1)

    scheduler.add_job(func=scheduled_task,
                      trigger='date',
                      run_date=notification_datetime,
                      args=[chat_id, notification_datetime, city],
                      id=chat_id)
    scheduler.start()

    return 'Scheduled several long running tasks.', 200
コード例 #4
0
#!/usr/bin/env python
# encoding: utf-8

from app import create_app
from app import scheduler

app = create_app()

scheduler.start()
if __name__ == "__main__":
    app.run(debug=True, host="0.0.0.0")
コード例 #5
0
ファイル: run_dev.py プロジェクト: ubnetdef/bank-api
#!/usr/bin/env python
from app import app, scheduler

scheduler.start()
app.run()
コード例 #6
0
def main():
    scheduler.add_job(schedule_job, 'interval', minutes=20)
    scheduler.start()
コード例 #7
0
def start_scheduler():
    scheduler.start()
    check_first()