[Python-checkins] cpython (3.4): Use try-finally idiom in example for locks in multiprocessing

andrew.svetlov python-checkins at python.org
Wed Jul 2 06:21:45 CEST 2014


http://hg.python.org/cpython/rev/34ec73494e74
changeset:   91520:34ec73494e74
branch:      3.4
parent:      91518:78fc2465f114
user:        Andrew Svetlov <andrew.svetlov at gmail.com>
date:        Wed Jul 02 07:21:03 2014 +0300
summary:
  Use try-finally idiom in example for locks in multiprocessing

files:
  Doc/library/multiprocessing.rst |  6 ++++--
  1 files changed, 4 insertions(+), 2 deletions(-)


diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst
--- a/Doc/library/multiprocessing.rst
+++ b/Doc/library/multiprocessing.rst
@@ -262,8 +262,10 @@
 
    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()

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list