[Python-ideas] Async API
Greg Ewing
greg.ewing at canterbury.ac.nz
Wed Oct 24 02:24:49 CEST 2012
Yury Selivanov wrote:
> def foo():
> connection = open_connection()
> try:
> spam()
> finally:
> [some code]
> connection.close()
>
> What happens if you run 'foo.with_timeout(1)' and timeout occurs at
> "[some code]" point?
I would say that vital cleanup code probably shouldn't do
anything that could block. If you really need to do that,
it should be protected by a finally clause of its own:
def foo():
connection = open_connection()
try:
spam()
finally:
try:
[some code]
finally:
connection.close()
--
Greg
More information about the Python-ideas
mailing list