Message413767
> If some code is used together with timeout() and this code calls
> `.cancel()` but forgot about `.uncancel()` in try/except/finally --
> timeout() never raises TimeoutError.
Could you show an example? I'm not sure from this description who cancels whom and where the try/except/finally is in relation to the rest.
If you have something that catches CancelledError and then ignores it, e.g.
while True:
try:
await <something>
except CancelledError:
pass
then that's an immortal task and it shouldn't be run inside a timeout.
If you have something that catches CancelledError once, e.g.
try:
await <big action>
finally:
await <cleanup>
there should be no need to call .uncancel() *unless* the <cleanup> may hang -- in that case you could write
try:
await <big action>
finally:
async with timeout(5):
await <cleanup>
I'm not sure that we should recommend using .uncancel() except in very special cases (e.g. when writing a timeout() context manager :-) and those cases should just be tested. |
|
Date |
User |
Action |
Args |
2022-02-23 02:52:33 | gvanrossum | set | recipients:
+ gvanrossum, njs, jab, asvetlov, alex.gronholm, chris.jerdonek, yselivanov, tinchester, iritkatriel, dreamsorcerer, ajoino |
2022-02-23 02:52:33 | gvanrossum | set | messageid: <1645584753.27.0.706374088427.issue46771@roundup.psfhosted.org> |
2022-02-23 02:52:33 | gvanrossum | link | issue46771 messages |
2022-02-23 02:52:33 | gvanrossum | create | |
|