New submission from Ethan Welty <[email protected]>:
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
----------
components: Tkinter
messages: 314160
nosy: ezwelty
priority: normal
severity: normal
status: open
title: Merely importing tkinter breaks parallel code (multiprocessing,
sharedmem)
type: crash
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue33111>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com