We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents e428092 + 9ae1873 commit 32d9c27Copy full SHA for 32d9c27
cron.go
@@ -178,8 +178,11 @@ func (c *Cron) run() {
178
}
179
180
181
-// Stop the cron scheduler.
+// Stop stops the cron scheduler if it is running; otherwise it does nothing.
182
func (c *Cron) Stop() {
183
+ if !c.running {
184
+ return
185
+ }
186
c.stop <- struct{}{}
187
c.running = false
188
cron_test.go
@@ -189,6 +189,13 @@ func TestLocalTimezone(t *testing.T) {
189
190
191
192
+// Test that calling stop before start silently returns without
193
+// blocking the stop channel.
194
+func TestStopWithoutStart(t *testing.T) {
195
+ cron := New()
196
+ cron.Stop()
197
+}
198
+
199
type testJob struct {
200
wg *sync.WaitGroup
201
name string
0 commit comments