-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
capture stack traces in worker panics #6
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e9f25ac
capture stack traces in worker panics
mumbleskates 99a4f59
update go
mumbleskates 1b3c69d
drop support for 1.20
mumbleskates 5fcdb87
move helper into test that always builds
mumbleskates 9a15da7
hopefully fix a rare flake
mumbleskates File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/wandb/parallel | ||
|
||
go 1.21 | ||
go 1.23.1 | ||
|
||
require github.com/stretchr/testify v1.9.0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,20 @@ import ( | |
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func assertPanicsWithValue(t *testing.T, expectedValue any, f func()) { | ||
t.Helper() | ||
|
||
defer func() { | ||
p := recover() | ||
if p == nil { | ||
t.Fatal("didn't panic but should have") | ||
} | ||
assert.Equal(t, expectedValue, p.(WorkerPanic).Panic) | ||
}() | ||
|
||
f() | ||
} | ||
|
||
func TestGroup(t *testing.T) { | ||
for _, test := range []struct { | ||
name string | ||
|
@@ -156,7 +170,7 @@ func testLimitedGroupMaxConcurrency(t *testing.T, name string, g Executor, limit | |
if shouldSucceed { | ||
assert.NotPanics(t, jobInserter.Wait) | ||
} else { | ||
assert.PanicsWithValue(t, "poison pill", jobInserter.Wait) | ||
assertPanicsWithValue(t, "poison pill", jobInserter.Wait) | ||
} | ||
}) | ||
} | ||
|
@@ -213,3 +227,21 @@ func testConcurrentGroupWaitReallyWaits(t *testing.T, name string, g Executor) { | |
testingGroup.Wait() | ||
}) | ||
} | ||
|
||
func TestCanGoexit(t *testing.T) { | ||
g := Unlimited(context.Background()) | ||
g.Go(func(context.Context) { | ||
// Ideally we would test t.Fatal() here to show that parallel now plays | ||
// nicely with the testing lib, but there doesn't seem to be any good | ||
// way to xfail a golang test. As it happens t.Fatal() just sets a fail | ||
// flag and then calls Goexit() anyway; if we treat nil recover() values | ||
// as Goexit() (guaranteed since 1.21 with the advent of PanicNilError) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... realizes what it means that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is some deep lore to how |
||
// we can handle this very simply, without needing a "double defer | ||
// sandwich". | ||
// | ||
// Either way, we expect Goexit() to work normally in tests now and not | ||
// fail or re-panic. | ||
runtime.Goexit() | ||
}) | ||
g.Wait() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, why CompareAndSwap? Is there a risk of setting
g.panicked
twice?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty positive i just wanted to make sure that specifically the first panic sticks, rather than just "any panic who cares"