При получении объекта 'ForkAwareLocal' отсутствует ошибка атрибута 'connection' при попытке добавить в список несколько процессов - PullRequest
0 голосов
/ 30 апреля 2020

Я пытаюсь создать несколько процессов для параллельного запуска функции и добавления результата в список общей памяти.

Вот соответствующий код:

from multiprocessing import Process, Manager
def gauss_prob(point, path_loc, l):
    //prod_sum calculated
    l.append((point, prod_sum))

//this is all inside of a while loop indexed by the variable curr
//list called unique_particles created containing x,y points
unique_particle_probs = []
with Manager() as manager:
    l = manager.list()
    processes = []
    for parts in unique_particles:
        p = Process(target=gauss_prob, args=(parts, curr, l))
        p.start()
        processes.append(p)
    for p in processes:
        p.join()
    unique_particle_probs = list(l)

Сообщение об ошибке Я получаю, когда я запускаю это:

Process Process-43:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/managers.py", line 788, in _callmethod
    conn = self._tls.connection
AttributeError: 'ForkAwareLocal' object has no attribute 'connection'

Во время обработки вышеупомянутого исключения произошло другое исключение:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/apple/PycharmProjects/WifiResearch/venv/bin/RSSGauss2.7.py", line 116, in gauss_prob
    l.append((point, prod_sum))
  File "<string>", line 2, in append
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/managers.py", line 792, in _callmethod
    self._connect()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/managers.py", line 779, in _connect
    conn = self._Client(self._token.address, authkey=self._authkey)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/connection.py", line 492, in Client
    c = SocketClient(address)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/connection.py", line 619, in SocketClient
    s.connect(address)
ConnectionRefusedError: [Errno 61] Connection refused
...