-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parallel execution issues on macOS #312
Comments
Thanks for clear explanation. I just tried doit with following patch:
I test this using doit own Works for me on linux. I suggest a command line argument to control this... Regarding changing the default. I am not clear in which situation you would have |
Yes Using the
According to the documentation |
Oh, sorry. You had already given an example. So the problem is usage of a closure as an action. Windows also has this limitation... Yes, I saw the docs regarding extra restrictions. Although it doesnt mention closures and i am not sure which restrictions from docs is the offending one. I will stick to my proposed solution of adding a command line argument to control this. And by default just use python's default. Maybe add a note on docs for MAC and Windows users to not use closures on actions. |
Ha yes, indeed: moving I'll do the test on the macOS of my coworker on Monday to confirm that it works there as well, but that looks good to me 🙂 |
I've just tried your patch on macOS and it works as expected. |
good, but i dont want to force use spawn on linux... So a fix/patch would need to:
|
Looks good to me 🙂 Maybe add a check if someone set |
(sorry for the wall of text, I tried to give as much info as possible, feel free to ask me clarification if something is unclear)
Context
It seems like the parallel execution feature of
doit
doesn't work on macOS (I noticed it on a coworker's laptop, being on Linux I never noticed any issue on my side).I investigated on my side and came up with a satisfying workaround/fix (force the use of threads on macOS).
Long story short, this is related to the fact that by default:
doit
usesmultiprocessing
for parallel executionmultiprocessing
usesfork
on Unix-like systemFor more information you can take a look at the issue I tackled on our side (scality/metalk8s#1354).
Here is a minimal
dodo.py
that reproduce the problem if you exectute on macOS (10.13 or higher):To be executed with
doit -n 4
.Note that the crash happen only when you're calling into Cocoa libraries (that why I added an
urllib
call, simply sleeping doesn't exhibit the behavior).What can be done
I know it's not really an
doit
issue per se, and after reading this very informative thread on the Python bugtracker one can see that the issue will probably disappear with Python 3.8 (wheremultiprocessing
will be usingspawn
instead offork
by default).But I believe that we may want to do something on
doit
side because Python 3.8 is not out yet (and people will keep using older Python for a while), so it may be interesting to have a fix/workaround indoit
itself.I think that the issue can be solved by calling either
multiprocessing.set_start_method('forkserver')
ormultiprocessing.set_start_method('spawn')
(I would go forspawn
since official Python is moving that way) before creating any subprocesses indoit
.If it doesn't work/it's too much work/outside the scope of
doit
, it's possible to instead mention the issue in the documentation about parallel execution (so that people are not surprised/know how to deal with).Or maybe simply disabling the use of
multiprocessing
on macOS (and using only threads).In any case, if you want to keep the support for
multiprocessing
on macOS, you may want to take a look now because the current code will not work in 3.8 (which will be usingspawn
by default): adding a call tomultiprocessing.set_start_method('spawn')
in the provideddodo.py
triggers a pickle error (which is not totally unexpected asspawn
has more constraints thantfork
, see here).Environment
The text was updated successfully, but these errors were encountered: