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

start of multiple simultaneous goroutines #191

Closed
Shukla-Ankur opened this issue Apr 18, 2019 · 2 comments
Closed

start of multiple simultaneous goroutines #191

Shukla-Ankur opened this issue Apr 18, 2019 · 2 comments

Comments

@Shukla-Ankur
Copy link

In my code, I try to connect to MySQL DB (within a cron function). In cases when this connection establishing takes time, cron starts running the registered function in another goroutine.
Is there any way to ensure that if a gorotuine has already been started, do not start a new one unless the previous one finishes?

@ytinirt
Copy link

ytinirt commented Apr 24, 2019

@Shukla-Ankur you can achieve that with Mutex or Channel simply in you code.

robfig pushed a commit that referenced this issue Jun 17, 2019
robfig pushed a commit that referenced this issue Jul 3, 2019
with cross-cutting concerns

These JobWrappers are provided:
- SkipIfStillRunning skips a job if the previous invocation is still running.
- DelayIfStillRunning blocks a job invocation until the previous one is done.
- Recover, to recover from panics in the job.

BREAKING: This removes the default behavior of recovering from job panics.
That must now be opted-into using WithChain(Recover(logger)).
Having it be the default behavior can be surprising (see issue #192)
and is at odds with most libraries.

Fixes #191
Fixes #192
robfig pushed a commit that referenced this issue Jul 11, 2019
with cross-cutting concerns

These JobWrappers are provided:
- SkipIfStillRunning skips a job if the previous invocation is still running.
- DelayIfStillRunning blocks a job invocation until the previous one is done.
- Recover, to recover from panics in the job.

BREAKING: This removes the default behavior of recovering from job panics.
That must now be opted-into using WithChain(Recover(logger)).
Having it be the default behavior can be surprising (see issue #192)
and is at odds with most libraries.

Fixes #191
Fixes #192
@robfig
Copy link
Owner

robfig commented Jul 11, 2019

You can use the new SkipIfAlreadyRunning JobWrapper in v3. Please have a look and let me know if you have any problems.

@robfig robfig closed this as completed Jul 11, 2019
haiheipijuan pushed a commit to haiheipijuan/cron that referenced this issue Jun 15, 2021
with cross-cutting concerns

These JobWrappers are provided:
- SkipIfStillRunning skips a job if the previous invocation is still running.
- DelayIfStillRunning blocks a job invocation until the previous one is done.
- Recover, to recover from panics in the job.

BREAKING: This removes the default behavior of recovering from job panics.
That must now be opted-into using WithChain(Recover(logger)).
Having it be the default behavior can be surprising (see issue robfig#192)
and is at odds with most libraries.

Fixes robfig#191
Fixes robfig#192
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

3 participants