-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e40bb84
commit 8c31f03
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import multiprocessing | ||
import multiprocessing.pool | ||
|
||
class NoDaemonProcess(multiprocessing.Process): | ||
@property | ||
def daemon(self): | ||
return False | ||
|
||
@daemon.setter | ||
def daemon(self, value): | ||
pass | ||
|
||
|
||
class NoDaemonContext(type(multiprocessing.get_context())): | ||
Process = NoDaemonProcess | ||
|
||
# We sub-class multiprocessing.pool.Pool instead of multiprocessing.Pool | ||
# because the latter is only a wrapper function, not a proper class. | ||
class NestablePool(multiprocessing.pool.Pool): | ||
def __init__(self, *args, **kwargs): | ||
kwargs['context'] = NoDaemonContext() | ||
super(NestablePool, self).__init__(*args, **kwargs) |