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

check if it is running when calling start() #54

Merged
merged 3 commits into from
Aug 10, 2016

Conversation

cloudfly
Copy link
Contributor

fix a bug,

call Start() more than once will start multiple run() goroutines to run the jobs.

@@ -123,6 +123,9 @@ func (c *Cron) Entries() []*Entry {

// Start the cron scheduler in its own go-routine.
func (c *Cron) Start() {
if c.running {
return
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method documentation says:

// Start the cron scheduler in its own go-routine.

But it's not what this code does, so docs would need to be updated if this change is to be merged.

@dmitshur
Copy link

See #46 which was an identical issue.

The conclusion seemed to be that it's better for your program to arrange it so that it doesn't call Start more than once.

@cloudfly
Copy link
Contributor Author

@shurcooL I think this nessesory to check running here.

As Stop() having a running status check, we can call Start() to start multiple schedulers, but Stop() can only stop one.

@@ -121,8 +121,11 @@ func (c *Cron) Entries() []*Entry {
return c.entrySnapshot()
}

// Start the cron scheduler in its own go-routine.
// Start the cron scheduler in its own go-routine if it is not running, otherwize it does nothing.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Start the cron scheduler in its own go-routine, or no-op if already started.

@robfig
Copy link
Owner

robfig commented Aug 9, 2016

OK, I guess this comes up enough and it's easy to resolve that might as well.. small tweak to comment please!

@robfig robfig merged commit 3625689 into robfig:master Aug 10, 2016
@robfig
Copy link
Owner

robfig commented Aug 10, 2016

Thank you!

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.

3 participants