From ee750d8f8da5a4789d6cae2879e6f7535baeef4c Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 2 Jul 2014 07:21:03 +0300 Subject: [PATCH] Use try-finally idiom in example for locks in multiprocessing --- Doc/library/multiprocessing.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst index 5fac7308017..276339842cd 100644 --- a/Doc/library/multiprocessing.rst +++ b/Doc/library/multiprocessing.rst @@ -262,8 +262,10 @@ that only one process prints to standard output at a time:: def f(l, i): l.acquire() - print('hello world', i) - l.release() + try: + print('hello world', i) + finally: + l.release() if __name__ == '__main__': lock = Lock()