Skip to content

Commit

Permalink
close channels
Browse files Browse the repository at this point in the history
  • Loading branch information
lostbean committed Dec 18, 2023
1 parent 5483950 commit 0f9b454
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions engine/server/engine/streaming/websocket_pump.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func NewWebsocketPump[T interface{}](ctx echo.Context, cors cors.Cors) (*Websock
return &WebsocketPump[T]{
websocket: conn,
inputChan: make(chan *T),
infoChan: make(chan *api_type.ResponseInfo),
ctx: ctxWithCancel,
cancelFunc: cancelFunc,
}, nil
Expand All @@ -62,6 +63,8 @@ func (pump WebsocketPump[T]) StartPumping() {
defer func() {
ticker.Stop()
pump.websocket.Close()
close(pump.inputChan)
close(pump.infoChan)
}()

logrus.WithFields(logrus.Fields{
Expand Down

0 comments on commit 0f9b454

Please sign in to comment.