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 on windows: daemonic processes are not allowed to have children #225

Closed
M-Kristof opened this issue Oct 18, 2019 · 7 comments
Closed

Comments

@M-Kristof
Copy link

M-Kristof commented Oct 18, 2019

I am encountering a problem when running lists of learners in a jupyterlab notebook on a windows machine.

For example, when trying out 'Balancing learner' of the introductory notebook,

import adaptive
adaptive.notebook_extension()

# Import modules that are used in multiple cells
import holoviews as hv
import numpy as np
from functools import partial
import random

def h(x, offset=0):
    a = 0.01
    return x + a**2 / (a**2 + (x - offset)**2)

learners = [adaptive.Learner1D(partial(h, offset=random.uniform(-1, 1)),
            bounds=(-1, 1)) for i in range(10)]

bal_learner = adaptive.BalancingLearner(learners)
runner = adaptive.Runner(bal_learner, goal=lambda l: l.loss() < 0.01)
runner.live_info()

I get the following error message:

future: <Task finished coro=<_wrap_awaitable() done, defined at C:\ProgramData\Anaconda3\lib\asyncio\tasks.py:596> exception=AssertionError('daemonic processes are not allowed to have children')>
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\asyncio\tasks.py", line 603, in _wrap_awaitable
    return (yield from awaitable.__await__())
  File "C:\ProgramData\Anaconda3\lib\site-packages\distributed\nanny.py", line 245, in start
    response = await self.instantiate()
  File "C:\ProgramData\Anaconda3\lib\site-packages\distributed\nanny.py", line 328, in instantiate
    result = await self.process.start()
  File "C:\ProgramData\Anaconda3\lib\site-packages\distributed\nanny.py", line 502, in start
    await self.process.start()
  File "C:\ProgramData\Anaconda3\lib\site-packages\distributed\process.py", line 33, in _call_and_set_future
    res = func(*args, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\distributed\process.py", line 190, in _start
    process.start()
  File "C:\ProgramData\Anaconda3\lib\multiprocessing\process.py", line 110, in start
    'daemonic processes are not allowed to have children'

It works fine on linux.

@akhmerov
Copy link
Contributor

Seems to be a general limitation of multiprocessing on windows: https://stackoverflow.com/questions/6974695/python-process-pool-non-daemonic

@basnijholt
Copy link
Member

This shouldn't happen because Windows should use distributed instead of multiprocessing:

if os.name == "nt":
if with_distributed:
_default_executor = distributed.Client
_default_executor_kwargs = {"address": distributed.LocalCluster()}
else:
_windows_executor_msg = (
"The default executor on Windows for 'adaptive.Runner' cannot "
"be used because the package 'distributed' is not installed. "
"Either install 'distributed' or explicitly specify an executor "
"when using 'adaptive.Runner'."
)
_default_executor_kwargs = {}
def _default_executor(*args, **kwargs):
raise RuntimeError(_windows_executor_msg)
warnings.warn(_windows_executor_msg)

Can you check if os.name == "nt" and adaptive.runner. _default_executor?

@M-Kristof
Copy link
Author

The answer is yes to both. It is using distributed.

@jbweston
Copy link
Contributor

This may well be a bug in distributed; further investigation needed.

@jbweston
Copy link
Contributor

possibly related: dask/distributed#2142 dask/distributed#2718

@basnijholt
Copy link
Member

We were able to reproduce this in #247 where we added tests for Windows.

It seems like you should just be able to use a ProcessPoolExecutor. When that PR is merged, it will become the default.

@jbweston
Copy link
Contributor

@M-Kristof, seems that #247 was merged and tests are passing on Windows.

I'll close this issue and you can re-open it if the problem resurfaces.

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

No branches or pull requests

4 participants