Skip to content

Commit

Permalink
fix: stop no longer waits
Browse files Browse the repository at this point in the history
Stop now cancels the context and exits.
This is to prevent double-close of already closed channel by pool.Wait function.

Signed-off-by: Marek Cermak <marek.cermak@tradeforge.app>
  • Loading branch information
CermakM committed Nov 24, 2024
1 parent 8611553 commit 7492bd2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module go.tradeforge.dev/background
go 1.22.0

require (
github.com/eapache/go-resiliency v1.6.0
github.com/eapache/go-resiliency v1.7.0
github.com/sourcegraph/conc v0.3.0
github.com/stretchr/testify v1.9.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/eapache/go-resiliency v1.6.0 h1:CqGDTLtpwuWKn6Nj3uNUdflaq+/kIPsg0gfNzHton30=
github.com/eapache/go-resiliency v1.6.0/go.mod h1:5yPzW0MIvSe0JDsv0v+DvcjEv2FyD6iZYSs1ZI+iQho=
github.com/eapache/go-resiliency v1.7.0 h1:n3NRTnBn5N0Cbi/IeOHuQn9s2UwVUH7Ga0ZWcP+9JTA=
github.com/eapache/go-resiliency v1.7.0/go.mod h1:5yPzW0MIvSe0JDsv0v+DvcjEv2FyD6iZYSs1ZI+iQho=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
Expand Down
4 changes: 1 addition & 3 deletions manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,13 @@ func (m *Manager) RunWithRetry(task TaskFunc, retry *retrier.Retrier) {
}

// Stop cancels the context of the manager and all its tasks.
func (m *Manager) Stop() error {
func (m *Manager) Stop() {
m.cancelFunc()
return m.pool.Wait()
}

// Wait blocks until all scheduled tasks have finished and propagate any panics spawned by a child to the caller.
// Wait returns an error if any of the tasks failed.
func (m *Manager) Wait() error {
defer m.cancelFunc()
return m.pool.Wait()
}

Expand Down

0 comments on commit 7492bd2

Please sign in to comment.