FileNotFoundError: 6 leaked semaphore objects to cleanup at shutdown

FileNotFoundError: 6 leaked semaphore objects to cleanup at shutdown

在简单地创建一个池时,我收到了以下信息(无限循环错误)。请注意,这与 shown here 不同,因为我没有尝试加载任何数据。路径缩写:

import multiprocessing
pool = multiprocessing.Pool()

FileNotFoundError: [Errno 2] No such file or directory: '/path/<input>'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/homebrew/anaconda3/envs/path/python3.9/multiprocessing/spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "/opt/homebrew/anaconda3/envs/path/python3.9/multiprocessing/spawn.py", line 125, in _main
    prepare(preparation_data)
  File "/opt/homebrew/anaconda3/envs/path/python3.9/multiprocessing/spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "/opt/homebrew/anaconda3/envs/path/python3.9/multiprocessing/spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "/opt/homebrew/anaconda3/envs/path/python3.9/multiprocessing/spawn.py", line 267, in run_path
    code, fname = _get_code_from_file(run_name, path_name)
  File "/opt/homebrew/anaconda3/envs/path/python3.9/multiprocessing/spawn.py", line 237, in _get_code_from_file
    with io.open_code(decoded_path) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/path/<input>'
/path/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 6 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '

奇怪的是,你没有做错任何事。降级到 python 3.7,完全相同的代码应该可以正常工作。参见 thread here