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

JobWrapper 'DelayIfStillRunning' don't work using 'WithChain' #316

Open
flpsaguiar opened this issue May 29, 2020 · 1 comment
Open

JobWrapper 'DelayIfStillRunning' don't work using 'WithChain' #316

flpsaguiar opened this issue May 29, 2020 · 1 comment

Comments

@flpsaguiar
Copy link

flpsaguiar commented May 29, 2020

Hi Robfig,

i'm trying to use the JobWrapper "DelayIfStillRunning", together with "WithChain", but it is not working (or it can't be used the way I'm trying to). I tested the JobWrapper "SkipIfStillRunning" and it works.

Here's an example of how I'm trying to use it.

c := cron.New(cron.WithChain(
	cron.DelayIfStillRunning(cron.DiscardLogger),
))
c.Start()

c.AddJob("17 * * * *", firstJob)
c.AddJob("18 * * * *", secondJob)

"firstJob" has an infinite loop in the Run function and even then the second Job is started.

@flpsaguiar flpsaguiar changed the title Option 'DelayIfStillRunning' don't work using 'WithChain' JobWrapper 'DelayIfStillRunning' don't work using 'WithChain' May 29, 2020
@KevinWu0904
Copy link

@flpsaguiar I thought you misunderstanding "DelayIfStillRunning". It was not used for different jobs, but for one job's adjacent triggers.

For your example:

c := cron.New(cron.WithChain(
	cron.DelayIfStillRunning(cron.DiscardLogger),
))
c.Start()

c.AddJob("17 * * * *", firstJob)

"firstJob" has an infinite loop in the Run function. OK, then the job will tigger every minute.

If you don't set DelayIfStillRunning, then it will trigger two concurrent Run function to execute each infinite loop. If you set DelayIfStillRunning, then the new function won't start until the first one 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

2 participants