-
-
Notifications
You must be signed in to change notification settings - Fork 716
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
Provide clearer message for multiprocess error #2520
Comments
To be clear, this fails if run within a script (it works fine in an interpretter): from dask.distributed import Client
client = Client()
# user code follows The solution is this from dask.distributed import Client
if __name__ == '__main__':
client = Client()
# user code follows This is exactly the same problem that exists with anything in Python that spins up processes, like a Another alternative is to not use processes with |
Dont know if this will work, but found suggestion on: dask/distributed#2520 which is exactly the problem I am harving. The code works when run in an interprettor and gives the stated error when run in a script.
This works for me, I am curious though, why does this fix the issue? |
@rgoggins This has to do with how the additional/child processes are created. Python has to "import" your script(s) in every child process. If you don't put initialization code (code that should only be run once) into the This is how I understand it at least. |
I've seen several issues where people are running into this - where would be a good place to clarify the expected usage in the documentation? |
Ah - a discussion for that is already happening over at #2708 In that case, this issue can be closed as a duplicate. |
See discussion on #2515 for details. In summary, if a user tries to use the
Client
object or uses multiprocessing in an unexpected way (especially when first starting out) they can run in to this error:The solution when this is encountered is typically making sure that your script is started in a
if __name__ == '__main__':
. If this doesn't apply to you then you usually have to do some fancier handling. Is there a way that the above exception can be caught by distributed/dask and provide a simpler or more clear message?The text was updated successfully, but these errors were encountered: