Commit ee750d8f authored by Andrew Svetlov's avatar Andrew Svetlov

Use try-finally idiom in example for locks in multiprocessing

parent 092b3cf6
...@@ -262,7 +262,9 @@ that only one process prints to standard output at a time:: ...@@ -262,7 +262,9 @@ that only one process prints to standard output at a time::
def f(l, i): def f(l, i):
l.acquire() l.acquire()
try:
print('hello world', i) print('hello world', i)
finally:
l.release() l.release()
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment