Uwsgi web app with cron tasks?

I have written an application using webpy (webpy.org). Part of this web application is repetitive background tasks for statistical functions. I have used python library APScheduler

to execute cron style schedules. Because app.run()

it allows the web server to work offline during development. This setup went fine.

However, when it was deployed, I found that APScheduler was no longer functional. The deployment procedure follows this article to a large extent . My entry point program still prints successful scheduling logs. But it looks like uwsgi pauses the web app launch (thread pause) when no requests are accepted. If I refresh the page, APScheduler will wake up, printing out multiple messages WARNING:apscheduler.scheduler:Run time of job "worker (trigger: cron[...], next run at: ..)" was missed by 0:04:36.389705

. They don't work as scheduled.

My question is how do I schedule cron style tasks when deploying a uwsgi web app. I saw that uwsgi has cron support. But I am wondering how can I mix it with my application like APScheduler (or replace it)? Tasks depend on multiple modules and dynamic properties of the application, so they cannot be easily converted to stand-alone .py programs.


source to share

1 answer

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



All Articles