Message314160
Merely importing tkinter breaks the use of parallel code on my system (Mac OSX 10.11.6, tested on Python 2.7.13 / 2.7.14 / 3.5.0 / 3.6.4, all barebones distributions installed with pyenv). I've tested this with both multiprocessing and sharedmem (see minimal scripts below).
The issue seems to apply only to functions that evoke multithreading within their respective package (e.g. `numpy.matmul()`, `cv2.SIFT.detectAndCompute()`). If I make the matrix in the scripts below much smaller (e.g. change `5000` to `5`), avoiding internal multithreading, the scripts work.
## with `multiprocessing`
```python
import numpy as np
import multiprocessing
import _tkinter
def parallel_matmul(x):
R = np.random.randn(3, 3)
return np.matmul(R, x)
pool = multiprocessing.Pool(4)
results = pool.map(parallel_matmul, [np.random.randn(3, 5000) for i in range(2)])
```
> *Code never exits and Python has to be force quit*
## with `sharedmem`
```python
import numpy as np
import sharedmem
import _tkinter
def parallel_matmul(x):
R = np.random.randn(3, 3)
return np.matmul(R, x)
with sharedmem.MapReduce() as pool:
results = pool.map(parallel_matmul,
[np.random.randn(3, 5000) for i in range(2)])
```
> sharedmem.sharedmem.SlaveException: slave process 1 killed by signal 11 |
|
Date |
User |
Action |
Args |
2018-03-20 19:20:56 | ezwelty | set | recipients:
+ ezwelty |
2018-03-20 19:20:56 | ezwelty | set | messageid: <1521573656.32.0.467229070634.issue33111@psf.upfronthosting.co.za> |
2018-03-20 19:20:56 | ezwelty | link | issue33111 messages |
2018-03-20 19:20:56 | ezwelty | create | |
|