Skip to content
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

Error starting up Client #516

Closed
stefanseefeld opened this issue Sep 12, 2016 · 9 comments
Closed

Error starting up Client #516

stefanseefeld opened this issue Sep 12, 2016 · 9 comments

Comments

@stefanseefeld
Copy link

The following chunk of code fails:

from distributed.client import *
import time

client = Client()

time.sleep(5)
print('five seconds later')

with:

distributed.utils - ERROR - 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

(plus a long traceback)

@mrocklin
Copy link
Member

Interestingly this only occurs if you add the import *

If you just do

from distributed import Client

Then this runs fine

@mrocklin
Copy link
Member

The minimal failing example appears to be as follows:

from distributed.client import *
import time

client = Client()

@mrocklin
Copy link
Member

Nope, I take it back. I can reproduce with the clean import

@mrocklin
Copy link
Member

mrocklin commented Sep 12, 2016

This may be resolved by #515

@mrocklin
Copy link
Member

This is, I believe, resolved. Thanks for reporting!

@stsievert
Copy link
Member

I believe I ran into this same issue, resolved by updating from 1.13.0 to 1.14.3.

from distributed import Client

client = Client()
ncores = sum([c for _, c in client.ncores().items()])
print(ncores)
# prints 0

client = Client('127.0.0.1:8786')
ncores = sum([c for _, c in client.ncores().items()])
print(ncores)
# prints 32

@wholmgren
Copy link

wholmgren commented Jun 6, 2017

I see this issue (the original post) on mac and linux machines with distributed 1.16.3.

edited to add: This is an issue when trying to run the code in a module. It works fine in the python interpreter or in jupyter notebooks.

@mrocklin
Copy link
Member

mrocklin commented Jun 6, 2017

By default Client() forks processes. If you use it within a module you should hide it within the __main__ block.

# client = Client()

if __name__ == '__main__':
    client = Client()
    ...

Alternatively you can choose to use threads safely.

client = Client(processes=False)

@wholmgren
Copy link

Ah, of course. Thanks. Sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants