Message291578
> The problem is that the task doesn't catch CancelledError, yet it disappears.
The problem is CancelledError is not raised, even it's thrown.
Task can't catch exception not raised. See below example which demonstrates how task works.
---
from asyncio import CancelledError
cancelled = False
def coro():
global cancelled
print(1)
yield (1,)
print("cancel")
cancelled = True
#print(2)
#yield (2,) # uncomment this line makes cancel success.
c = coro()
while True:
try:
if cancelled:
r = c.throw(CancelledError)
else:
r = c.send(None)
except StopIteration:
print("end")
break
except CancelledError:
print("cancelled")
break |
|
Date |
User |
Action |
Args |
2017-04-13 00:19:13 | methane | set | recipients:
+ methane, abacabadabacaba, yselivanov |
2017-04-13 00:19:13 | methane | set | messageid: <1492042753.82.0.420596114718.issue30048@psf.upfronthosting.co.za> |
2017-04-13 00:19:13 | methane | link | issue30048 messages |
2017-04-13 00:19:12 | methane | create | |
|