-
Notifications
You must be signed in to change notification settings - Fork 25
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
fix(validation): asyncSpawns run #1039
Conversation
emizzle
commented
Dec 13, 2024
- annotates run with raises: []
- asyncSpawns run, to ensure there are no escaping exceptions
6f8e0d1
to
bf0c26a
Compare
|
||
proc stop*(validation: Validation) {.async.} = | ||
await validation.running.cancelAndWait() | ||
if not validation.running.isNil and not validation.running.finished: |
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.
Ugh, when does this happen (the nil case)? If you call stop before start?
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.
yes
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.
It's a good question. Th nil check prevents SIGSEGV and the finished
check prevents Defects like "future was completed more than once". Both are a PITA to debug and these checks prevent that pain. However, if validation.running
is nil, then we could raise a Defect
imo, because something didn't quite go right and we're in a bad state. BUT, we're stopping the module, so do we really care if validation.running
is already nil? Probably not.
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.
LGTM
- annotates run with raises: [] - asyncSpawns run, to ensure there are no escaping exceptions
bf0c26a
to
c1d15da
Compare
- annotates run with raises: [] - asyncSpawns run, to ensure there are no escaping exceptions