mirror of https://github.com/python/cpython
Use try-finally idiom in example for locks in multiprocessing
This commit is contained in:
parent
092b3cf671
commit
ee750d8f8d
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue