Closed cburgess closed 1 year ago
Confirming that this works fine on Linux with Python 3.10, so it does appear to be a MacOS thing.
Given that I don't have a Mac, I'll have to defer to @0xDEC0DE on this one.
I am able to reproduce the error with both Python 3.8.3 and 3.10.4 on MacOS.
A cursory web search infers that multiprocessing
has some explicit protection against being run in a global scope, and indeed, this version of the script runs without complaint:
#!/usr/bin/env python
import pylru
import soufi
LRU_CACHE = pylru.lrucache(size=1024)
def main():
finder = soufi.finder.factory('centos',
'vim-minimal',
'7.4.629-8.el7_9',
soufi.finder.SourceType.os,
cache_backend='dogpile.cache.memory',
cache_args=dict(cache_dict=LRU_CACHE))
print(finder.find())
if __name__ == '__main__':
main()
Soufi should probably make a good-faith effort to catch the RuntimeError
and present a useful error message.
Bizarre. Ok then.
Did you want to submit a fix for this Nic?
If you attempt to use soufi on MacOS you will hit multiprocess issues. As an example I created the following simply test script.
On my Mac I have installed python 3.10.3 via pyenv. If I setup a venv with the latest soufi and then try and run the above script (and the fix for #29) I get an error about calling
freeze_support()
which is a windows only thing, but the error is coming frommultiprocessing/spawn.py
. MacOS and Windows share the same start method (spawn
, see https://docs.python.org/3/library/multiprocessing.html) so I suspect the issue is actually related to the use ofspawn
vsfork
. Note this script works fine on Linux.