나는 with
에 대한 내용을 Python &에 실 었다고 이해하면 with
문은 작업 완료시 자원을 닫아야합니다.contextlib.closing() thread safe - Python
일부 DB 작업 수행 & connection
을 (를) 사용하여 with 문을 사용 중입니다. 하지만 스레드 안전성에 대해서는 확신하지 못합니다.
with contextlib.closing(sqlite3.connect(self.dbName)) as connection:
# Do Something
내가 context.closing()
는 멀티 스레딩을 처리 할 수 있는지 여부를 알고 싶어하거나 내가 threading.Lock()
&이
context.closing()
에 추가 잠금 않는 전화를해야 할
with
lock = threading.Lock()
with lock:
#Do Something
처럼 나는 또한에 대한
threading
사용하여 읽기
lock = threading.Lock()
with lock:
with contextlib.closing(sqlite3.connect(self.dbName)) as connection:
# Do Something
지연 응답을 위해 죄송합니다. 그것은 사물을 이해하는 데 도움이됩니다. 고맙습니다 :) – OO7