trio icon indicating copy to clipboard operation
trio copied to clipboard

Add API for changing the context of a running task.

Open Fuyukai opened this issue 3 years ago • 8 comments

This is implemented as an asynchronous context manager (allowing arbitrary nesting).

Fuyukai avatar Aug 01 '21 01:08 Fuyukai

Codecov Report

Merging #2086 (24b3814) into master (f8cb817) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2086   +/-   ##
=======================================
  Coverage   99.55%   99.55%           
=======================================
  Files         114      116    +2     
  Lines       14751    14785   +34     
  Branches     2341     2344    +3     
=======================================
+ Hits        14685    14719   +34     
  Misses         44       44           
  Partials       22       22           
Impacted Files Coverage Δ
trio/lowlevel.py 100.00% <ø> (ø)
trio/_core/__init__.py 100.00% <100.00%> (ø)
trio/_core/_context.py 100.00% <100.00%> (ø)
trio/_core/tests/test_context.py 100.00% <100.00%> (ø)

codecov[bot] avatar Aug 01 '21 01:08 codecov[bot]

Hmm, I'd call this function changed_context so that the with statement reads like a reasonable English phrase.

smurfix avatar Aug 01 '21 07:08 smurfix

That's inconsistent with every other context manager in the library.

Fuyukai avatar Aug 01 '21 07:08 Fuyukai

If there's no objections to this in the next four days I'm going to merge this unilaterally.

Fuyukai avatar Aug 04 '21 11:08 Fuyukai

I have some mixed feelings about the "I'm going to commit this regardless of review once it's been up for a week" -- I think based on typical review habits in this project that a week of silence doesn't actually constitute a mandate to go ahead.

This feature is blocking the project I'm working on. Given that it's a ten line feature change, relatively simple, and that the review was primarily about semantics I think that it's fair to expect this could be pushed through quickly.

Fuyukai avatar Aug 04 '21 15:08 Fuyukai

This feature is blocking the project I'm working on. Given that it's a ten line feature change, relatively simple, and that the review was primarily about semantics I think that it's fair to expect this could be pushed through quickly.

You could inline change_context() into your project in the meantime -- it doesn't actually use any private APIs. I'm not trying to pass judgment on whether pushing on this change's timeline was abstractly fair or not; mostly wanted to flag that I was personally somewhat taken aback by the approach.

oremanj avatar Aug 04 '21 15:08 oremanj

@Fuyukai any progress on this?

pquentin avatar Aug 13 '21 13:08 pquentin

Hi, I picked this back up again after ~five months of being a writer :)

I addressed all the comments raised by @oremanj. I also wish to apologise for my rash behaviour and threatening a unilateral merge.

Fuyukai avatar Dec 23 '21 04:12 Fuyukai