2020年5月6日 星期三

[Python] with lock

with 語法
with some_lock:
    # do something...

等於
some_lock.acquire()
try:
    # do something...
finally:
    some_lock.release()

https://www.bogotobogo.com/python/Multithread/python_multithreading_Using_Locks_with_statement_Context_Manager.php

沒有留言: