Robust signal handling for Python