Skip to content

Commit

Permalink
Fixed non working panic recoverer (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-littlefarmer authored Aug 8, 2023
1 parent da05a0d commit ae66864
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ func newExecutor() executor {
}

func runJob(f jobFunction) {
panicHandlerMutex.RLock()
defer panicHandlerMutex.RUnlock()

if panicHandler != nil {
defer func() {
if r := recover(); r != nil {
panicHandler(f.funcName, r)
}
}()
}
f.runStartCount.Add(1)
f.isRunning.Store(true)
callJobFunc(f.eventListeners.onBeforeJobExecution)
Expand Down Expand Up @@ -209,17 +219,6 @@ func (e *executor) run() {
go func() {
defer e.jobsWg.Done()

panicHandlerMutex.RLock()
defer panicHandlerMutex.RUnlock()

if panicHandler != nil {
defer func() {
if r := recover(); r != nil {
panicHandler(f.funcName, r)
}
}()
}

if e.limitModeMaxRunningJobs > 0 {
switch e.limitMode {
case RescheduleMode:
Expand Down

0 comments on commit ae66864

Please sign in to comment.