Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New sched module #283

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

New sched module #283

wants to merge 11 commits into from

Conversation

rubiojr
Copy link
Contributor

@rubiojr rubiojr commented Oct 15, 2024

Fixes #279

The sched module exposes a simple interface to schedule tasks, powered by chrono.

import sched
import time

once := sched.once("1s", func(){
  print("once")
})

cron := sched.cron("*/1 * * * * *", func(){
  print("hola")
})
print(cron.is_running())

every := sched.every("1m", func() {
  print("every 1 minute")
})

for {
  time.sleep(1)
}

@rubiojr rubiojr changed the title [WiP] New sched module New sched module Oct 15, 2024
@rubiojr
Copy link
Contributor Author

rubiojr commented Oct 15, 2024

This is ready for some 👀

@myzie
Copy link
Collaborator

myzie commented Nov 7, 2024

@rubiojr - one aspect of this I'm thinking about is whether this should have some cleanup behavior built in.

For example with the pgx module, I automatically close connections when the context is done:
https://github.com/risor-io/risor/blob/main/modules/pgx/pgx_conn.go#L104-L112

That means that whatever context was passed to run the Risor VM can be used to cancel and automatically close any connections created during the VM run.

Similarly, I wonder if all schedules created with this module should automatically be cleaned up when the VM context is cancelled. Thoughts?

(This is mainly relevant when using Risor as an embedded library)

@rubiojr
Copy link
Contributor Author

rubiojr commented Nov 7, 2024

@myzie let me have a closer look, I didn't think of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sched module to schedule tasks
2 participants