Skip to content
Advertisement

Tag: locking

Share RLock between multiple instances of Python with multiprocessing

Consider this MWE: When this script is executed, it instantiates the_setup and serves it. Then I want clients to be able to do things like this from other scripts: However, I get RuntimeError: RLock objects should only be shared between processes through inheritance. If the with the_setup.hold_hardware(): is removed, it works fine but then I cannot guarantee that the hardware

When spawn processes, Does Lock have different id?

I’m trying to figure out how Lock works under the hood. I run this code on MacOS which using “spawn” as default method to start new process. Output: The Lock works in my code. However, the ids of lock make me confused. Since idare different, are they still same one lock or there are multiple locks and they somehow communicate

Advertisement