cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Is there a way to catch the cancel button or the interrupt button in a Databricks notebook?

Jfoxyyc
Valued Contributor

I'm running oracledb package and it uses sessions. When you cancel a running query it doesn't close the session even if you have a try catch block because a cancel or interrupt issues a kill command on the process. Is there a method to catch the cancel or interrupt? In an ipynb notebook I could use except KeyboardInterrupt.

4 REPLIES 4

Aviral-Bhardwaj
Esteemed Contributor III

Please share a code block by that we can test in our system and provide you correct solution

AviralBhardwaj

Jfoxyyc
Valued Contributor

Just find yourself a long running query or create a view that cross joins a quadrillion records (make sure you have the ability to kill this session). Then import oracledb in a notebook, connect to that server, and query that long running query. Proceed to hit cancel in the notebook cell or interrupt in the notebook at the top right. The session doesn't close, you'd need to connection.close(force=True) or pool.close(force=True).

What i'm looking for is a way to catch the 'cancel' button in a cell or the 'interrupt' button in a notebook so I can capture this in a try: except: block and issue the close() command.

Anonymous
Not applicable

Hi @Jordan Foxโ€‹ 

Hope everything is going great.

Just wanted to check in if you were able to resolve your issue. If yes, would you be happy to mark an answer as best so that other members can find the solution more quickly? If not, please tell us so we can help you. 

Cheers!

jonathan-dufaul
Valued Contributor

I'm having the same issue and this has been frustrating as heck.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group