Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.1K
Visualizações
Stop execution of Colab notebook from within a cell based on condition

Basically what I am trying to do is if a condition is met, then the execution of the current cell and all subsequent cells is canceled. Here is the idea if exit() stopped the notebook execution (but it only stops the execution of the cell it is run in)

yes_and_no_list = ['yes', 'y', 'no', 'n']
response = ''
while not response.lower() in yes_and_no_list:
  response = input("Continue running notebook?")

if response in yes_and_no_list[2:]:
    print("Notebook execution aborted.")
    exit()

....so I am wondering if there is piece of code or a notebook magic that I can replace 'exit()' with and will stop the execution of the entire Colab notebook?

I have tried the response to this question: How to terminate current colab session from notebook cell

...but if I replace exit() with !kill $(ps aux | awk '{print $2}') it doesn't seem to print the line above it, "Notebook execution aborted.", so I am confused by how it works.

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda