nteract/papermill

Cells not running after an exception caught with ipython custom exception handler

Aberta

#518 aberto em 25 de jun. de 2020

 (8 comentários) (0 reação) (0 responsável)Python (402 forks)batch import
bughelp wanted

Métricas do repositório

Stars
 (5.381 estrelas)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

When configuring a custom exception handler in iPython with: ip.set_custom_exc inside a notebook there is a strange and buggy behaviour in papermill.

The notebook runs until the cell the raises an exception (that is handled by the custom handler), and then the notebook return with the cells after the current cell marked as "Pending". No exception is raised and the next cells are not executed.

Example:

Cell 1 (running ok):

x = 5
print(x)

Cell 2 (custom exception):

class MyException(BaseException):
    pass

ip = get_ipython()
def general_exception_handler(self, etype, exc, tb, tb_offset=None):
    print("special handle")

ip.set_custom_exc((MyException,), general_exception_handler)
raise MyException('ads')

Cell 3:

# This does not raise an exception because it is not running, cell status is "pending"
1 / 0

Guia do colaborador