-
Notifications
You must be signed in to change notification settings - Fork 51
Allow to spawn workers inside daemon #1067
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
base: develop
Are you sure you want to change the base?
Changes from 3 commits
ca55275
e4891a3
a218223
1307ae8
ad8ab82
1b94f7b
23ed92f
1db1e18
fccccda
3fcd5bf
8c22a41
01386ae
d7ffefa
c147b20
7efdfbc
efaeb17
f03d2fd
ec93ddb
008e9e1
3b89a44
c429016
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,8 +83,8 @@ def Process(*args, **kwds): | |
| if v.major == 3 and v.minor >= 8: | ||
| args = args[1:] | ||
|
|
||
| if Pool.ALLOW_DAEMON: | ||
| return Process(*args, **kwds) | ||
| if not Pool.ALLOW_DAEMON: | ||
| return PyPool.Process(*args, **kwds) | ||
|
|
||
| return _Process(*args, **kwds) | ||
|
|
||
|
|
@@ -167,13 +167,18 @@ def __init__(self, n_workers=-1, backend="multiprocess", **kwargs): | |
| if n_workers <= 0: | ||
| n_workers = multiprocessing.cpu_count() | ||
|
|
||
| self.pool_config = {"n_workers": n_workers, "backend": backend} | ||
| self.pool = PoolExecutor.BACKENDS.get(backend, ThreadPool)(n_workers) | ||
|
|
||
| def __setstate__(self, state): | ||
| self.pool = state["pool"] | ||
| log.warning("Nesting multiprocess executor") | ||
| self.pool_config = state["pool_config"] | ||
| backend = self.pool_config.get("backend", ThreadPool) | ||
bouthilx marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| n_workers = self.pool_config.get("n_workers", -1) | ||
| self.pool = PoolExecutor.BACKENDS.get(backend, ThreadPool)(n_workers) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit unsure about this part. If the object is serialized and passed to the subprocess, the deserialization step will have the effect or creating another pool of n_workers, no?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we maybe able to pass a queue instead to avoid creating multiple pools |
||
|
|
||
| def __getstate__(self): | ||
| return dict(pool=self.pool) | ||
| return {"pool_config": self.pool_config} | ||
|
|
||
| def __enter__(self): | ||
| return self | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.