-
-
Notifications
You must be signed in to change notification settings - Fork 725
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
Create default Client during unit tests #2515
Comments
FYI I am using stdlib unittest and am starting the tests from a test suite that is called from the command line via
|
That is a common Python message if you try to do multiprocessing things at import time. Typically the solution is to place multiprocessing things under the In your case you might bypass this by using a client that only uses threads
If you have any desire to help catch that error and have us print something nicer that would be a very welcome contribution. This question comes up a lot. |
There is not currently any blessed way to say "just get me a client whatever it takes". Currently the rationale for this is that people may want different defaults. For example as discussed above you may want to avoid processes, while currently that's the default. So currently including code like what you share above may be ideal. |
Ok thanks @mrocklin. I ended up mocking the Client object in my tests since right now I only have a few that use the Client object. I decided to do this after looking at all the logic in distributed's pytest fixtures (since we aren't currently using pytest it is harder to use them). |
OK, any interest in writing up the multiprocessing error message as a separate issue? It would be nice to help users with that. Python's error message is confusing to many people. |
@mrocklin I thought about this more this weekend, would you say it is "better" practice to have software using dask |
There are cases for everything :) The concern I was referring to above was in creating a client if it doesn't already exist. We might want the user to have some say in how we do that. We might not though. I'm totally open to a function that creates a default client if it doesn't already exist. That just doesn't currently exist, and we've been defaulting to "ask the user" so far. |
Makes sense. That is exactly what I ended up doing for the functions I've been playing with. The user can provide a |
I have some code using distributed that gets the same error message as #516 when run on travis ci. I am creating my client inside a function call run by the "user" if it is not explicitly provided by doing:
What is the suggested way to create a default client if the user hasn't created one? Or am I using this all wrong. My goal is to use distributed to compute things in parallel without the user needing to worry about how to create a client, but if they want to get fancy they can provide their own or I'll use the existing one.
The text was updated successfully, but these errors were encountered: