I was trying to run a python script with GNU parallel. Everything seems to work, except for the atexit routine used inside the python script. It seems, after ctrl+c, parallel is killing the python process without giving python a chance to call the registered atexit routine. How to make parallel a bit nicer towards the child processes?
Here is an example to show the behaviour.
test_signal.py:
#!/usr/bin/env python3
import time
import sys
import atexit
def cleanup():
print('cleanup called', flush=True)
atexit.register(cleanup)
time.sleep(60)
print('completed process', sys.argv[1])
Tested with the command:
chmod +x test_signal.py
./test_signal.py 1 # this works as expected when using ^C
parallel -j 4 ./test_signal.py {} ::: $(seq 1 12) # this one does not