diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2014-07-02 04:21:03 (GMT) |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2014-07-02 04:21:03 (GMT) |
commit | ee750d8f8da5a4789d6cae2879e6f7535baeef4c (patch) | |
tree | 866a7ef9cc97df8e1097c7b0c2d88638a1c8528c /Doc/library/multiprocessing.rst | |
parent | 092b3cf67117b3857f111bdb752e847eebd9e9b6 (diff) | |
download | cpython-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.rst | 6 |
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() |