LINUX.ORG.RU

История изменений

Исправление rtxtxtrx, (текущая версия) :

import multiprocessing as mp

_lock = mp.RLock()

def worker(...):
  ...
  with _lock:
    mp_dict['shit'] = ... 

mp_dict = mp.Manager().dict()

p1 = mp.Process(target=worker, args=(...))
p1.start()

p2 = mp.Process(target=worker, args=(...))
p2.start()

p1.join()
p2.join()

Исправление rtxtxtrx, :

import multiprocessing as mp

_lock = mp.RLock()

def worker(...):
  with _lock:
    mp_dict['shit'] = ... 

mp_dict = mp.Manager().dict()

p1 = mp.Process(target=worker, args=(...))
p1.start()

p2 = mp.Process(target=worker, args=(...))
p2.start()

p1.join()
p2.join()

Исходная версия rtxtxtrx, :

import multiprocessing as mp

_lock = mp.RLock()

def worker(...):
  with _lock:
    mp_dict['shit'] = ... 

mp_dict = mp.Manager().dict()

p1 = mp.Process(target=worker, args=(...))
p1.start()

p2 = mp.Process(target=worker, args=(...))
p2.start()