2

I am running some code with Python's concurrent.futures module, and I am having issues running it. I am on Windows 10 and using Python 3.8. I am trying to run a simulation, which is running fine on the Mac that my friend has. I tried setting

Max Workers = 1, :cf.ProcessPoolExecutor(max_workers=1) as executor: as was suggested in another thread, but it also also failed. I am kind of out of ideas.

The stack trace looks like this—

 Error Description: BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.

Process SpawnProcess-1:
Traceback (most recent call last):
  File "C:\Users\Lotfi\AppData\Local\Programs\Python\Python38\lib\multiprocessing\process.py", line 315, in _bootstrap
    self.run()
  File "C:\Users\Lotfi\AppData\Local\Programs\Python\Python38\lib\multiprocessing\process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Lotfi\AppData\Local\Programs\Python\Python38\lib\concurrent\futures\process.py", line 233, in _process_worker
    call_item = call_queue.get(block=True)
  File "C:\Users\Lotfi\AppData\Local\Programs\Python\Python38\lib\multiprocessing\queues.py", line 116, in get
    return _ForkingPickler.loads(res)
AttributeError: Can't get attribute 'runTest' on <module '__main__' (built-in)>
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "<stdin>", line 11, in doit2
  File "C:\Users\Lotfi\AppData\Local\Programs\Python\Python38\lib\concurrent\futures\process.py", line 484, in _chain_from_iterable_of_lists
    for element in iterable:
  File "C:\Users\Lotfi\AppData\Local\Programs\Python\Python38\lib\concurrent\futures\_base.py", line 611, in result_iterator
    yield fs.pop().result()
  File "C:\Users\Lotfi\AppData\Local\Programs\Python\Python38\lib\concurrent\futures\_base.py", line 439, in result
    return self.__get_result()
  File "C:\Users\Lotfi\AppData\Local\Programs\Python\Python38\lib\concurrent\futures\_base.py", line 388, in __get_result
    raise self._exception
concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.
Redowan Delowar
  • 1,580
  • 1
  • 14
  • 36
ZTZaorish
  • 23
  • 5
  • A possible duplicate of—https://stackoverflow.com/questions/15900366/all-example-concurrent-futures-code-is-failing-with-brokenprocesspool – Redowan Delowar Mar 05 '21 at 22:49
  • Good point, i added : if __name__ == '__main__': doit2() , but forgot to show it here, it still messes things up. I also saved it, as was recommended. – ZTZaorish Mar 06 '21 at 00:32
  • I may have this fixed: def doit2(): dists = df['dist'] n1s = df['n1'] n2s = df['n2'] alphas = df['alpha'] start = time.perf_counter() # with cf.ThreadPoolExecutor() as executor: with cf.ProcessPoolExecutor(max_workers=1) as executor: results = executor.map(runTest, dists, n1s, n2s, alphas) for r in results: # print(r) output.append(r) finish = time.perf_counter() print(f"Finished in {round(finish-start, 2)} second(s)") if __name__ == '__doit2__': doit2() At least the error is gone – ZTZaorish Mar 06 '21 at 00:35

0 Answers0