Access to manage scheduled tasks from python?

I would like to allow regular users of the site (not programmers) to manage scheduler processes.

Is there an access to the task scheduler processes from the python level to enable the creation of a simplified UI, e.g. to preview scheduled tasks, how much time is left until the next task, skip running the next task, etc. ?

2 Likes

I am doing some research about this, and found this package, also available
for in anvil.

APScheduler · PyPI

Let me know if you have succes to get it up and running. I am thinking to use this as a task manager for rendering software.

In Anvil, scheduled tasks are the way to run code at specific times/intervals: Anvil Docs | Scheduled Tasks

Reading the docs, I don’t see it answer the question if these task can be scheduled via code vs IDE.

I think it is only IDE, but would love the feature to do it in the code.

1 Like

You’re right, they’re scheduled via the IDE. You could pretty easily write a single IDE scheduled function that would go through a data table and execute functions listed there on whatever schedule is stored in the data table.

2 Likes

That is a great IDE.

So the scheduler would have to be a frequency as your most frequent task?

And how would you store the functions? (thinking/typing out loud here)
As strings? that you then can use anvil.server.call on?

That sounds reasonable.

As a string sounds like the best bet. I probably wouldn’t use anvil.server.call, since that would have some overhead. We’re already running in the server, so I’d just use some variation on globals()[functionname]() It’d take some playing around to get right.

Parameters could be stored as a simple object column, with some basic substitutions (e.g. the current user’s email, etc)

1 Like

Thanks for refining my first take.

A dictionary makes much more sense!