I have the following test_mpi.py
python script:
from mpi4py import MPI
import time
class Foo:
def __init__(self):
print('Creation object.')
def __del__(self):
print('Object destruction.')
foo = Foo()
time.sleep(10)
If I execute it without recourse to mpiexec, using a simple python test_mpi.py
, pressing CTRL+C after 5s, I get the following output:
ngreiner@Nathans-MacBook-Pro:~/Documents/scratch$ python test_mpi.py
Creation object.
^CTraceback (most recent call last):
File "test_mpi.py", line 26, in <module>
time.sleep(10)
KeyboardInterrupt
Object destruction.
ngreiner@Nathans-MacBook-Pro:~/Documents/scratch$
If I embed it within an mpiexec execution, using mpiexec -np 1 python test_mpi.py
, again pressing CTRL+C after 5s, I now get:
ngreiner@Nathans-MacBook-Pro:~/Documents/scratch$ mpiexec -np 1 python test_mpi.py
Creation object.
^Cngreiner@Nathans-MacBook-Pro:~/Documents/scratch$
The traceback from python and the execution of the __del__ method have disappeared. The main problem for me is the non-execution of the __del__ method, which is supposed to make some clean-up in my actual application.
Any idea how I could have the __del__ method executed when the Python execution is launched from mpiexec ?
Thank you very much in advance for the help,
(My system configuration: macOS High sierra 10.13.6, Python 3.7.4, open-mpi 4.0.1, mpi4py 3.0.2.)