-
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.
Merge pull request #10 from fabiocfabini/master
dotproduct parallelized
- Loading branch information
Showing
2 changed files
with
99 additions
and
51 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) |
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