Forums

You must run uWSGI with the --enable-threads option for the scheduler to work.

Hi,

in my app I need to run the BackgroundScheduler from the apscheduler package, but I keep getting the "You must run uWSGI with the --enable-threads option for the scheduler to work." error.

I've read about this and I concluded that it's not possible to use it in PythonAnywhere. For me this is a deal breaker.

There is some way to make it work in PythonAnywhere?

Thx

No, it would not work on PythonAnywhere. You may consider some solutions from https://help.pythonanywhere.com/pages/AsyncInWebApps/

The same problem. How to fix it?

If you want to run your own scheduler, I'd recommend setting it up to run as an always-on task, or just setting up a scheduled task on the "Tasks" page for each thing that you want to schedule. When websites run in a production environment like PythonAnywhere, you will have multiple processes running at once -- in some environments they would even be on multiple different machines. So a simple scheduler that tries to run in a thread hanging off the website code would not work, because it would have multiple instances running and scheduled actions would happen multiple times.

Is this still the case about scheduler

Yes, it is. See my comment above -- running the scheduler inside your website code is always going to be a problem in a production deployment (on any platform, not just PythonAnywhere) where there are multiple copies of your website code running at the same time.