PythonAnywhere Forums

APScheduler and sched module don't work

Hi, I'm running a flask web app and need to schedule a delayed task (checking whether the user has timed out) from within the script. I tried both the default python sched module and the APScheduler package and both code versions work on my local machine but not on here. Are these kinds of modules not allowed or am I missing something pythonanywhere specific?

I don't think either of those will work in our environment (that's just from a quick reading of their docs). I would think that you could implement the user timeout thing more easily by storing a time of when your user will time out and then checking that against the current time in your web app. That's assuming that I understand correctly what you're trying to do.

Yeah, I kind of already do that. I just don't know when to check against the current time, afaik Flask apps don't have a main loop. That's why I did the job thing.

Anyway, I moved my app to another host where my solution worked, but thanks.

For anyone looking, according to this the recommended way of using apscheduler with Flask is by employing rpc.

This exact setup won't work on pythonanywhere, the solution here would be to create scheduled tasks (premium account) with custom commands.

Interesting -- thanks!