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: 

Catch when a notebook fails and terminate command in threaded parallel notebook run

cmilligan
Contributor II

I have a command that is running notebooks in parallel using threading. I want the command to fail whenever one of the notebooks that is running fails. Right now it is just continuing to run the command.

Below is the command line that I'm currently running:

q = Queue()
worker_count = 3 
 
def run_notebook(notebook):
  print(notebook)
  dbutils.notebook.run(notebook, 30, {"begin_date": begin_date, "end_date": end_date})
 
def run_tasks(function, q):
    while not q.empty():
      value = q.get()
      function(value)
      q.task_done()
 
for x in range(len(notebook_steps)): 
  for x in notebook_steps[x]:
    q.put(x)
      
  for i in range(worker_count):
    t=Thread(target=run_tasks, args=(run_notebook, q))
    t.daemon = False
    t.start()
 
  q.join()

0 REPLIES 0

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