[Python-ideas] Async API
greg.ewing at canterbury.ac.nz
Tue Oct 30 06:53:09 CET 2012
Yury Selivanov wrote:
> So in your example scheduler would never ever has a question of
> interrupting c2(), because it wasn't called with any restriction/timeout.
> There simply no reason to interrupt it ever.
But there's nothing to stop someone writing
yield from with_timeout(10.0, c1())
print("That's cool, I can cope with that")
Also, it's not just TimeoutErrors that are a potential
problem, it's any asynchronous exception. For example,
the task calling c1() might get cancelled by another
task while c2() is blocked. If cancelling is implemented
by throwing in an exception, you have the same problem.
> Then you need scheduler to know if it is in its finally or not. Because its
> c2() which was run with a timeout. It's c2() code that may be subject to
I'm really not following your reasoning here. You seem to
be speaking as if with_timeout() calls only have an effect
one level deep. But that's not the case -- the frame that a
TimeoutError gets thrown into by with_timeout() can be
nested any number of yield-from calls deep.
More information about the Python-ideas