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

Overlapping of Jobs #83

Open
abhi3700 opened this issue Sep 27, 2024 · 1 comment
Open

Overlapping of Jobs #83

abhi3700 opened this issue Sep 27, 2024 · 1 comment

Comments

@abhi3700
Copy link

Suppose, a job takes longer time than usual & then the next thread opens for the new job. In this situation there could be an overlapping. I want to avoid this to happen.

A situation like this:
image

Is there a property available to set in a job such that it disallow overlapping of the 2 jobs?

Expecting a code like this:

let job1 = Job::new_async("1/2 * * * * *", move |_uuid, _lock| {
        Box::pin(async move {
            if let Err(e) = perform_task_1().await {
                error!("Error executing Job 1: {}", e);
            } else {
                info!("Job 1 executed successfully.");
            }
        })
    })
    .unwrap()
    .set_allow_overlap(false);
@abhi3700 abhi3700 changed the title Overlapping of a Jobs Overlapping of Jobs Sep 28, 2024
@abhi3700
Copy link
Author

I think I can protect this by having Mutex for a local data type.
And in case of using a DB (with drivers normally having states as Mutex type), I need to maintain a field there that locks when something is running inside a Job & then release lock (& thereby change the state) when done.

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

No branches or pull requests

1 participant