Python: Why is the multiprocessing lock shared among processes here?
问题 I am trying to share a lock among processes. I understand that the way to share a lock is to pass it as an argument to the target function. However I found that even the approach below is working. I could not understand the way the processes are sharing this lock. Could anyone please explain? import multiprocessing as mp import time class SampleClass: def __init__(self): self.lock = mp.Lock() self.jobs = [] self.total_jobs = 10 def test_run(self): for i in range(self.total_jobs): p = mp