File tree Expand file tree Collapse file tree 1 file changed +19
-17
lines changed Expand file tree Collapse file tree 1 file changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -209,25 +209,27 @@ func (scheduler *Scheduler) runningJobCount() int {
209
209
func (scheduler * Scheduler ) runJobs (t time.Time ) {
210
210
runnableJobs := scheduler .getRunnableJobs (t )
211
211
for _ , job := range runnableJobs {
212
- function := func () {
213
- channel := make (chan bool , 1 )
214
- go func () {
215
- job .run (t )
216
- channel <- true
217
- }()
218
- select {
219
- case <- channel :
220
- return
221
- case <- time .After (jobMaxExecutionDuration ):
222
- jobStat := JobStat {
223
- IsSuccess : false ,
224
- Err : ErrJobTimeout ,
225
- ScheduledTime : t ,
226
- RunDuration : jobMaxExecutionDuration ,
212
+ function := func (job Job ) func () {
213
+ return func () {
214
+ channel := make (chan bool , 1 )
215
+ go func () {
216
+ job .run (t )
217
+ channel <- true
218
+ }()
219
+ select {
220
+ case <- channel :
221
+ return
222
+ case <- time .After (jobMaxExecutionDuration ):
223
+ jobStat := JobStat {
224
+ IsSuccess : false ,
225
+ Err : ErrJobTimeout ,
226
+ ScheduledTime : t ,
227
+ RunDuration : jobMaxExecutionDuration ,
228
+ }
229
+ job .addStat (jobStat )
227
230
}
228
- job .addStat (jobStat )
229
231
}
230
- }
232
+ }( job )
231
233
if err := scheduler .workerPool .Submit (function ); err != nil {
232
234
jobStat := JobStat {IsSuccess : false , Err : err , ScheduledTime : t }
233
235
job .addStat (jobStat )
You can’t perform that action at this time.
0 commit comments