Skip to content

Commit

Permalink
Order defer functions properly
Browse files Browse the repository at this point in the history
Deferred function calls are executed in Last In First Out order after the surrounding function returns:
https://go.dev/blog/defer-panic-and-recover
  • Loading branch information
don4get committed Aug 29, 2024
1 parent 0cedaff commit 589c3e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion go/parquet/pqarrow/file_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,13 @@ func (fr *FileReader) ReadRowGroups(ctx context.Context, indices, rowGroups []in
wg.Add(np) // fan-out to np readers
for i := 0; i < np; i++ {
go func() {
defer wg.Done()
defer func() {
if pErr := recover(); pErr != nil {
err := utils.FormatRecoveredError("panic while reading", pErr)
results <- resultPair{err: err}
}
}()
defer wg.Done()
for {
select {
case r, ok := <-ch:
Expand Down

0 comments on commit 589c3e4

Please sign in to comment.