summaryrefslogtreecommitdiffstats
path: root/Doc/library/multiprocessing.rst
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2014-07-02 04:21:03 (GMT)
committerAndrew Svetlov <andrew.svetlov@gmail.com>2014-07-02 04:21:03 (GMT)
commitee750d8f8da5a4789d6cae2879e6f7535baeef4c (patch)
tree866a7ef9cc97df8e1097c7b0c2d88638a1c8528c /Doc/library/multiprocessing.rst
parent092b3cf67117b3857f111bdb752e847eebd9e9b6 (diff)
downloadcpython-ee750d8f8da5a4789d6cae2879e6f7535baeef4c.zip
cpython-ee750d8f8da5a4789d6cae2879e6f7535baeef4c.tar.gz
cpython-ee750d8f8da5a4789d6cae2879e6f7535baeef4c.tar.bz2
Use try-finally idiom in example for locks in multiprocessing
Diffstat (limited to 'Doc/library/multiprocessing.rst')
-rw-r--r--Doc/library/multiprocessing.rst6
1 files changed, 4 insertions, 2 deletions
diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst
index 5fac730..2763398 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()