Testing APScheduler Locally with Foreman

I use wizards to run my python application locally and test it. This is what I do:

foreman start -e local.env

I am trying to add scheduling to my application, so I installed apscheduler and completed the Heroku tutorial . I added this line to my Procfile:

clock: python clock.py

And my clock.py looks like this:

from apscheduler.scheduler import Scheduler

sched = Scheduler()

@sched.interval_schedule(minutes=1)
def timed_job():
    print 'This job is run every minute.'

@sched.cron_schedule(day_of_week='mon-fri', hour=17)
def scheduled_job():
    print 'This job is run every weekday at 5pm.'

sched.start()
print 'Scheduler started'

while True:
    pass

So, when I start the wizard, I see this:

11:54:05 web.1   | started with pid 16709
11:54:05 clock.1 | started with pid 16710
11:54:05 web.1   | 2014-01-23 11:54:05 [16709] [INFO] Starting gunicorn 18.0
11:54:05 web.1   | 2014-01-23 11:54:05 [16709] [INFO] Listening at: http://0.0.0.0:5000 (16709)
11:54:05 web.1   | 2014-01-23 11:54:05 [16709] [INFO] Using worker: sync
11:54:05 web.1   | 2014-01-23 11:54:05 [16713] [INFO] Booting worker with pid: 16713

It looks correct, but now I expect that the synchronization process should log a message every minute, but it is not. In fact, I do not get any logs from the clock process, is this normal?

I found that when I leave it for a while, and then Ctrl + C, I can see the logs coming from the clock process, but only some of them:

  • " "
  • " ". , 2 .

: ? , ?

. , , -. , , , , :

foreman run -e local.env python app/myapp.py runserver

, , - . , .

+4

Source: https://habr.com/ru/post/1523328/


All Articles