Message362690
This is a very interesting question.
In asyncio, task cancellation is not executed on `task.cancel()` call immediately but the task is *marked* for cancellation.
The actual cancellation requires a context switch (await asyncio.sleep(0) or similar) to propagate `asyncio.CancelledError` into the task code and unwind the exception.
As I said, the test needs a context switch between `cancel()` call and analyzing the state after the task cancellation.
Futures are canceled immediately, that's why the previous implementation passed uvloop's test suite untouched. Unfortunately, it had own flaws.
Also please note, sock_connect()/sock_accept() were implemented this way about two years before my changes, they also suffer from cancel-without-actual-cancellation problems as well. |
|
Date |
User |
Action |
Args |
2020-02-26 12:39:03 | asvetlov | set | recipients:
+ asvetlov, ned.deily, abacabadabacaba, lukasz.langa, yselivanov |
2020-02-26 12:39:03 | asvetlov | set | messageid: <1582720743.89.0.419347264589.issue30064@roundup.psfhosted.org> |
2020-02-26 12:39:03 | asvetlov | link | issue30064 messages |
2020-02-26 12:39:03 | asvetlov | create | |
|