[Python-ideas] Async API

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Oct 29 06:05:24 CET 2012


Yury Selivanov wrote:

>     def coro1():
>         try:
>             with timeout(1.0):
>                 yield from coro2() # 1
>         finally:
>             try:
>                 with timeout(1.0):
>                     yield from coro2() # 2
>             except TimeoutError:
>                 pass
> 
>     def coro2():
>         try:
>             block()
>             yield # 3
>             action()
>         finally:
>             block()
>             yield # 4
>             another_action()
> 
> Now, if "coro2" is suspended at #4 -- it shouldn't be interrupted with
> TimeoutError.
> 
> If, however, "coro2" is at #3 -- it can be, and it doesn't matter was it 
> called from #1 or #2.

What is your reasoning behind asserting this? Because it's inside
a try block of its own? Because it's subject to a nested timeout?
Something else?

-- 
Greg



More information about the Python-ideas mailing list