On Unix, mutiprocessing works well with default creating new process method (fork). However, if I set the creating method as spawn, python exits abnormally. I could not get the reason why python exits abnormally. Here is my simple testing code:
def test_mp():
num_processes = 3
print("chengs++: mp start a new process with method: ", get_start_method())
set_start_method('spawn', force=True)
print("chengs++: mp start a new process with method after resetting to spawn: ", get_start_method())
with Pool(num_processes) as pool:
results = pool.starmap(
doubler,
zip(
[2] * num_processes,
[1] * num_processes,
),
)
print(results)
def doubler(number, r):
result = number * 2 + r
return result
If you have any clue, please let me know. Thanks in advance.