Skip to content
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

Merged
merged 1 commit into from
Dec 16, 2024
Merged

Conversation

emizzle
Copy link
Contributor

@emizzle emizzle commented Dec 13, 2024

  • annotates run with raises: []
  • asyncSpawns run, to ensure there are no escaping exceptions

@emizzle emizzle force-pushed the fix/fix-async-futures/2-validation branch from 6f8e0d1 to bf0c26a Compare December 13, 2024 03:48

proc stop*(validation: Validation) {.async.} =
await validation.running.cancelAndWait()
if not validation.running.isNil and not validation.running.finished:
Copy link
Member

@gmega gmega Dec 13, 2024

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Contributor Author

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.

Copy link
Member

@gmega gmega left a 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
@emizzle emizzle force-pushed the fix/fix-async-futures/2-validation branch from bf0c26a to c1d15da Compare December 16, 2024 05:07
@emizzle emizzle enabled auto-merge December 16, 2024 05:07
@emizzle emizzle added this pull request to the merge queue Dec 16, 2024
Merged via the queue into master with commit bef1160 Dec 16, 2024
17 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Dec 16, 2024
- annotates run with raises: []
- asyncSpawns run, to ensure there are no escaping exceptions
@emizzle emizzle deleted the fix/fix-async-futures/2-validation branch December 16, 2024 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants