arutaku
arutaku

Reputation: 6087

Python 3 "Lock" for both: threads and processes

I have been trying to code a cache in python 3 and I want to avoid concurrency issues for both, threads and process.

I have been using threading for thread-safe code, and multiprocessing for process safety.

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 "generic" Lock to do this stuff or something like that.

Thank you in advance ;-)

Upvotes: 4

Views: 779

Answers (1)

David Heffernan
David Heffernan

Reputation: 612794

You cannot use the same class for both in-process locks, and cross-process locks. The implementations are quite different.

Your current strategy is the correct one.

Upvotes: 1

Related Questions