Author ezwelty
Recipients ezwelty, ned.deily, ronaldoussoren, terry.reedy
Date 2018-03-27.14:53:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1522162427.17.0.467229070634.issue33111@psf.upfronthosting.co.za>
In-reply-to
Content
@ronaldoussoren: The order of the imports made no difference. Even with the call at the top, I got endless errors with both 'spawn' and 'forkserver', with or without importing a graphics backend. Only 'fork' works, and only if a graphics package is not imported.

** HOWEVER **

Setting method='spawn' or 'forkserver' and force=True at top, or calling multiprocessing.set_start_method in __main__ does work (when run as scripts from command line). It's a shame to have to give up the convenience of 'fork', but this is a start.

```
import multiprocessing
multiprocessing.set_start_method("spawn", force=True)
import numpy as np
# import _tkinter

def parallel_matmul(x):
    R = np.random.randn(3, 3)
    return np.matmul(R, x)

if __name__ == '__main__':
    # multiprocessing.set_start_method("spawn", force=False)
    pool = multiprocessing.Pool(4)
    results = pool.map(parallel_matmul, [np.random.randn(3, 5000) for i in range(2)])
```
History
Date User Action Args
2018-03-27 14:53:47ezweltysetrecipients: + ezwelty, terry.reedy, ronaldoussoren, ned.deily
2018-03-27 14:53:47ezweltysetmessageid: <1522162427.17.0.467229070634.issue33111@psf.upfronthosting.co.za>
2018-03-27 14:53:47ezweltylinkissue33111 messages
2018-03-27 14:53:47ezweltycreate