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

Add a "nursery_end" instrumentation. #1317

Open
wants to merge 6 commits into
base: master
from

Conversation

@smurfix
Copy link
Contributor

@smurfix smurfix commented Nov 26, 2019

The use case: One of your tasks raises an exception. The nursery cancels
all other tasks and waits for them to end. If one of these tasks
swallows the cancellation, e.g. because of a deadlock, you need a way
to find the original exception.

The use case: One of your tasks raises an exception. The nursery cancels
all other tasks and waits for them to end. If one of these tasks
swallows the cancellation, e.g. because of a deadlock, you need a way
to find the original exception.
@smurfix smurfix force-pushed the smurfix:task_raised branch from 2ca42df to 6fc5c57 Nov 26, 2019
@codecov
Copy link

@codecov codecov bot commented Nov 26, 2019

Codecov Report

Merging #1317 into master will decrease coverage by 0.01%.
The diff coverage is 94.28%.

@@            Coverage Diff             @@
##           master    #1317      +/-   ##
==========================================
- Coverage   99.69%   99.67%   -0.02%     
==========================================
  Files         106      106              
  Lines       13008    13042      +34     
  Branches      996      998       +2     
==========================================
+ Hits        12968    13000      +32     
- Misses         23       25       +2     
  Partials       17       17
Impacted Files Coverage Δ
trio/_core/_run.py 99.73% <100%> (ø) ⬆️
trio/_abc.py 100% <100%> (ø) ⬆️
trio/_core/tests/test_run.py 99.87% <92.59%> (-0.13%) ⬇️
@oremanj
Copy link
Member

@oremanj oremanj commented Nov 26, 2019

I think it's unnecessary to have a separate task_raised instrument to capture tasks exiting with exceptions, when you can just define a task_exited instrument that checks whether its outcome argument is an Error.

It looks like you're also calling task_raised when an exception is raised out of the nested child of a nursery. That's a functionality that's not currently exposed to the Instrument API -- maybe this PR could provide just that, under a more specific name like nested_child_exited?

as per @oremanj's feedback
@smurfix
Copy link
Contributor Author

@smurfix smurfix commented Nov 27, 2019

Fair enough, thanks for the feedback. Fixed.

@smurfix
Copy link
Contributor Author

@smurfix smurfix commented Nov 27, 2019

Umm, Azure seems not to have picked up the latest change ?

@smurfix smurfix closed this Nov 27, 2019
@smurfix smurfix reopened this Nov 27, 2019
@smurfix
Copy link
Contributor Author

@smurfix smurfix commented Nov 27, 2019

you can just define a task_exited instrument that checks whether its outcome argument is an Error.

… except that we don't have that yet.

@njsmith OK to simply add an outcome or exception argument to the task_exited instrumentation? Otherwise we'd need deprecation and a new method and all that.

@smurfix
Copy link
Contributor Author

@smurfix smurfix commented Nov 27, 2019

… or I could simply set task.outcome=outcome before calling task_exited

@smurfix smurfix force-pushed the smurfix:task_raised branch from ac3aae0 to 29a7db5 Nov 27, 2019
@smurfix smurfix changed the title Add a "task_raised" instrumentation. Add a "nursery_end" instrumentation. Nov 27, 2019
@oremanj
Copy link
Member

@oremanj oremanj commented Nov 27, 2019

Ah, for some reason I thought we already passed the final outcome to the instrument... my bad!

I'm going to defer to @njsmith on the backwards compatibility policy for instruments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.