Domanda

I wrote an app using webpy (webpy.org). Part of this web app is recurring background tasks for statistical functions. I used APScheduler python library to perform cron style schedules. Because app.run() let webpy run in standalone mode during development. This setup worked out fine.

However, when it's deployed, I discovered that APScheduler no longer functions. Deployment procedure pretty much follows this article. My entry point program still prints successful scheduling logs. But it appears that uwsgi will suspend the running webpy app (making the thread suspended) when no requests are received. If I refresh a page, APScheduler will wakeup, printing a few WARNING:apscheduler.scheduler:Run time of job "worker (trigger: cron[...], next run at: ..)" was missed by 0:04:36.389705 messages. They are not running according to the schedule.

My question is, how do I schedule cron style tasks when deploying a uwsgi webpy app. I saw uwsgi itself has cron support. But I wonder how I can mix it with my app, like APScheduler (or replace it)? The tasks depends on a few modules and dynamic properties of the app, so they can't be easily converted into standalone .py programs.

È stato utile?

Soluzione

If the ApsScheduler requires threads, you should enable them with --enable-threads in uWSGI

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top