papermill icon indicating copy to clipboard operation
papermill copied to clipboard

Pass signals down to kernel

Open rgbkrk opened this issue 5 years ago • 3 comments

I've got some users that would like to be able to do cleanup within a notebook when it receives a certain signal, using the standard python library's signal package:

def cleanup(signum, frame):
    print("cleaning up")
    sys.exit(2)


signal.signal(signal.SIGTERM, cleanup)

Right now papermill doesn't appear to pass the message on when it is killed with a SIGTERM.

rgbkrk avatar May 27 '20 22:05 rgbkrk

Use case:

A scheduled notebook kicks off a job on a different service (e.g. genie). When the scheduler kills the execution of my notebook, I want the notebook as it shuts down to kill the job running on the other service.

rgbkrk avatar May 27 '20 22:05 rgbkrk

I think this is a good idea, might need implementation back in nbclient to support it. I'll look a bit deeper into what's needed.

MSeal avatar May 27 '20 22:05 MSeal

Hey @MSeal @willingc, any idea if this is scoped for the near future?

ElTav avatar Mar 04 '24 23:03 ElTav