【问题标题】:Heroku web and clock idle seems idle in the same timeHeroku 网络和时钟空闲似乎同时空闲
【发布时间】:2017-06-14 18:12:14
【问题描述】:

您好,我想知道有什么方法可以防止时钟在网络中闲置 同一个应用

这是我的 Procfilefile web: gunicorn badmintonApp:app clock: python cron.py

我的 cron.py 是

from apscheduler.schedulers.blocking import BlockingScheduler
import subprocess
import os
import datetime
import requests
from crawler import googleExcelCrawler

sched = BlockingScheduler()


@sched.scheduled_job('interval', minutes=360)
def crawler_job():
    googleExcelCrawler.syncExcelToDB(os.environ.get('GoogleAuthKey'),"1sdEYj_w57iQaFhD5eNNOMLEhMbzlnhs7vR8Lz5RlChA")
    print('This job is insert data')
    print('This job is run every 360 minutes.')
@sched.scheduled_job('interval', minutes=3)
def timed_job():
    response = requests.get(os.environ.get('CURRENTDOMAIN'))
    print("Current Page Status " +str(response.status_code ))
sched.start()

我尝试每分钟请求一次我的域,并希望在 6 小时后抓取该作业,但似乎无法正常工作....

有什么方法可以防止时钟在网络上闲置吗?

【问题讨论】:

    标签: python python-3.x heroku cron clock


    【解决方案1】:

    防止这种情况的唯一方法是改用爱好测功机。
    在免费的测功机上,当网络进程进入睡眠状态时,所有其他进程都会这样做。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-25
      • 2017-04-19
      • 2012-08-09
      • 2011-01-31
      • 1970-01-01
      • 1970-01-01
      • 2023-02-03
      • 1970-01-01
      相关资源
      最近更新 更多