Python 3 "Lock" for both: threads and processes

I am trying to encode a cache in python 3 and I want to avoid concurrency problems for both threads and processes.

I used threading for thread safe code and multiprocessing for process security.

I can solve my problem using Lock from threading and Lock from multiprocessing at the same time. But I was wondering if there is a β€œcommon” Lock for this or something like that.

Thank you in advance, -)

+4
source share
1 answer

You cannot use the same class for locks in a process, or for locks of cross processes. The implementations are quite different.

Your current strategy is correct.

+1
source

All Articles