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.
The first try at manually using spawn and channels worked, but if there
was an exception raised, it'd print a stack trace like this instead of
being handled nicely
The way to get around this would be to have the channel also be able to
take an exception, and resuce exceptions in the spawn block and send
them on the channel, then raise them in the main thread. This is a lot
of boilerplate work. I started writing a thing to do this for us, then
realized it was basically the promise pattern, and that someone else
probably has done that. I was a little hesitant to pull in this library
but it's not that large, and seems to do a good job.
So now when there is an exception we get the nicer output since this
takes care of all the steps to reraise exceptions in the right spot:
But then I realized that you can't actually call get clusters and get
teams at the same time, since you need to know the teams in order to
list their clusters. And this whole time for completion we were making
an extra call to get teams, since get_clusters with no args makes it's
own call to get teams. So I removed that unnecessary call from the
completion. The unhandeled exception problem though is a potential
problem in get_clusters, so it makes sense to use the new Promise
library there I think.