django / asgiref

ASGI specification and utilities
https://asgi.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
1.46k stars 207 forks source link

Revert "Fix task cancellation propagation to subtasks when using sync… #453

Closed carltongibson closed 5 months ago

carltongibson commented 5 months ago

… middleware (#435)"

This reverts commit 0503c2c4df06dbe56f04689fe537325f28dbbe8b.

Fixes #452.

I don't know if there's a better way, but reviewing #435 it seemed likely there might be an issue, so it might be worth reverting and then taking a bit more time there.

@ttys0dev do you have any thoughts?

carltongibson commented 5 months ago

@felixxm This fixed the intermittent Django failures for me. Do you want to give it a run to confirm? Thanks.

felixxm commented 5 months ago

TBH, I was not able to reproduce it locally :sweat_smile:

ttys0dev commented 5 months ago

@ttys0dev do you have any thoughts?

Well reverting would reintroduce the original bug which prevented task cancellation from working correctly so probably reverting isn't the best option here.

I don't know if there's a better way, but reviewing #435 it seemed likely there might be an issue, so it might be worth reverting and then taking a bit more time there.

I think the django test may have been relying on the previous incorrect task cancellation exception propagation, so the test itself might need fixing.

carltongibson commented 5 months ago

@ttys0dev I'd be grateful if you could take a look.

The output sent when the test fails shows that the main process request task isn't being correctly cancelled with this change in place.

(The timeout is for the application communicator in the test, not the app itself. The communicator gets the timeout because the app didn't return a response, because the http.disconnect was processed.)

carltongibson commented 5 months ago

Important to note, the original bug only affects cases where shield is being used, which is quite niche, compared to unknown scope of the issue with this patch in place.

carltongibson commented 5 months ago

@andrewgodwin @ttys0dev is looking now, so I suggest we hold until tomorrow. Hopefully we can work out the issue.

If we don't have progress I can roll a 3.8.1, and we can re-add this again more leisurely.

andrewgodwin commented 5 months ago

Sounds like a good plan to me. This sort of thing always happens when we do fixes to the deep internals :)

ttys0dev commented 5 months ago

Think I have a proper fix for this in #455.

carltongibson commented 5 months ago

Closing in favour of #455.