Skip to content

Commit

Permalink
another try to remove job observer leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
vintikzzz committed Oct 9, 2024
1 parent 9826729 commit dce5d1a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions services/job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ func (s *Observer) Push(v LogItem) {
if s.closed {
return
}
go func() {
select {
case <-time.After(5 * time.Minute):
return
case s.C <- v:
return
}
}()
select {
case <-time.After(5 * time.Minute):
return
case s.C <- v:
return
}
}

func (s *Observer) Close() {
Expand Down Expand Up @@ -171,7 +169,7 @@ func (s *Job) ObserveLog() *Observer {

func (s *Job) pushToObservers(l LogItem) {
for _, o := range s.observers {
o.Push(l)
go o.Push(l)
}
}

Expand Down

0 comments on commit dce5d1a

Please sign in to comment.