【问题标题】:Scheduled Jobs with Custom Clock Processes in Python with APScheduler is not running使用 APScheduler 的 Python 中具有自定义时钟进程的计划作业未运行
【发布时间】:2019-08-05 12:13:23
【问题描述】:

我将我的 scrapy 项目推送到 heroku。我需要自动化一些任务。因此,我从文档中了解了使用 Apsheduler 的自定义时钟。 这是我的目录结构:

.
├── bin
│   └── testargs.py
├── clock.py
├── Dockerfile
├── :hrsZp[do
├── newsfetch
│   ├── __init__.py
│   ├── items.py
│   ├── middlewares.py
│   ├── pipelines.py
│   ├── __pycache__
│   │   ├── __init__.cpython-34.pyc
│   │   ├── middlewares.cpython-34.pyc
│   │   ├── pipelines.cpython-34.pyc
│   │   └── settings.cpython-34.pyc
│   ├── settings.py
│   └── spiders
│       ├── indiatv.py
│       ├── __init__.py
│       ├── ndtv.py
│       ├── __pycache__
│       │   ├── indiatv.cpython-34.pyc
│       │   ├── __init__.cpython-34.pyc
│       │   ├── ndtv.cpython-34.pyc
│       │   ├── republic.cpython-34.pyc
│       │   ├── thehindu.cpython-34.pyc
│       │   └── zee.cpython-34.pyc
│       ├── republic.py
│       ├── thehindu.py
│       └── zee.py
├── p1.py
├── Procfile
├── requirements.txt
├── scrapy.cfg
└── setup.py

5 directories, 30 files

这是我的需求文件

Scrapy>=1.0.2
cffi>=1.12.2
psycopg2
APScheduler==3.0.0

这是我的clock.py文件

from apscheduler.schedulers.blocking import BlockingScheduler

sched = BlockingScheduler()

@sched.scheduled_job('interval', minutes=3)
def timed_job():
    print('This job is run every three minutes.')

sched.start()

我没有收到任何消息(此作业每三分钟运行一次)在我的 heroku 日志中打印。我已提交所有更改并部署应用程序。请帮助运行我的脚本,以便我进一步自动化任务。

这是日志的当前状态:

2019-03-14T14:27:40.979762+00:00 heroku[clock.1]: State changed from crashed to starting
2019-03-14T14:27:47.752630+00:00 heroku[clock.1]: Starting process with command `: python clock.py`
2019-03-14T14:27:48.437785+00:00 heroku[clock.1]: State changed from starting to up
2019-03-14T14:27:50.480830+00:00 heroku[clock.1]: State changed from up to crashed
2019-03-14T14:27:50.466390+00:00 heroku[clock.1]: Process exited with status 0

【问题讨论】:

    标签: python python-3.x heroku scrapy heroku-cli


    【解决方案1】:

    2019-03-14T14:27:47.752630+00:00 heroku[clock.1]: Starting process with command ': python clock.py'

    您的 Procfile 中似乎有一个错字,因为该命令应为 'python clock.py'(请注意缺少的冒号)。 Procfile 的正确行是: clock: python clock.py

    此外,如果您还没有这样做,请扩大时钟进程。在 Heroku CLI 中使用命令heroku ps:scale clock=1

    有关详细信息,请参阅Heroku page for APScheduler

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多