Hi Guido, Hi List,

And yet having a try/finally around a yield-from is an easy recipe for 
> resisting cancellation -- it is all too convenient to put another 
> yield-from in the finally clause, and then you are requiring multiple trips 
> through the event loop.
>

This is why I would love to have a well-documented function in the standard
library, where someone thought of all those corner-cases, and the function
either handles those, raises an exception or there is something in the
documentation telling the programmer DON'T DO THAT!

>
> Where are the finalizers you need called and what do they do? And why do 
> you need them called when you're shutting down the process?
>

I am writing an RPC-like system, along the lines of

@coroutine
def server(self):
    open_database()
    try:
        yield from getattr(self, yield from read_command())()
    finally:
        close_database()

now, there is a command to shut down the server, and I would like
the database to be properly closed for every server. First time I
discovered all of this was actually when I was pressing Ctrl-C
and realized it didn't close the database, something I always
kept for granted in a finalizer...

I am sure all this can be achieved differently, but nevertheless I think
a well thought out cancel method would still be a very nice thing to
have.

Greetings

Martin

Reply via email to