Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
DebbieE
Community Champion
Community Champion

F2 Capacity. spark.stop() at the end of the notebook but still running after this command

 I have this at the end of a notebook (And I am in F2 Capacity

 

# Stop the Spark session
spark.stop()
 
But I can;t run another notebook afterwards because it thinks it is still running.  If I go into Monotor it still says in progress. i have to cancel it manually in Monitor. 
 
I really need the stop command to work. Is there something I am doing wrong?
1 ACCEPTED SOLUTION

@Anonymous Thanks for sharing,

 

I guess the best option is to have one "master" notebook orchestrate the running of the other notebooks, as you mention (I have never tried it myself).

 

However I think the most updated link for use in Fabric Notebook is this one: https://learn.microsoft.com/en-us/fabric/data-engineering/notebook-utilities

 

More specifically: https://learn.microsoft.com/en-us/fabric/data-engineering/notebook-utilities#reference-a-notebook

 

This is for the Fabric Notebookutils.

The link you provided is for Azure Synapse Analytics. Or am I missing something?

 

I do however believe I have experienced that a function which was listed in Azure Synapse Analytics mssparkutils, but not listed in Fabric Notebookutils, still worked in Fabric Notebook.

 

But according to the docs, I think Fabric Notebookutils (ref. the links in this comment) should be the most updated one for use inside Fabric?

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @DebbieE,

In fact, you not need to run these processing one by one. You can invoke other notebook codesnip or directly invoke/reference other notebooks by NotebookUtils functions:

NotebookUtils (former MSSparkUtils) for Fabric - Microsoft Fabric | Microsoft Learn

If you want stop all the cost of fabric capacity resource usage, it should be more suitable to 'pause' on the capacity itself at azure side.

Pause and resume your capacity - Microsoft Fabric | Microsoft Learn

Update: thanks for frithjof_v 's reminder, I update and modify the reference link to notebookutils.

Regards,

Xiaoxin Sheng

@Anonymous Thanks for sharing,

 

I guess the best option is to have one "master" notebook orchestrate the running of the other notebooks, as you mention (I have never tried it myself).

 

However I think the most updated link for use in Fabric Notebook is this one: https://learn.microsoft.com/en-us/fabric/data-engineering/notebook-utilities

 

More specifically: https://learn.microsoft.com/en-us/fabric/data-engineering/notebook-utilities#reference-a-notebook

 

This is for the Fabric Notebookutils.

The link you provided is for Azure Synapse Analytics. Or am I missing something?

 

I do however believe I have experienced that a function which was listed in Azure Synapse Analytics mssparkutils, but not listed in Fabric Notebookutils, still worked in Fabric Notebook.

 

But according to the docs, I think Fabric Notebookutils (ref. the links in this comment) should be the most updated one for use inside Fabric?

DebbieE
Community Champion
Community Champion

I have 4 notebooks which I want to run in a sequence.

 

So I join them together and run, It just sticks on the first Notebook and doesnt move to the next notebook

 

DebbieE_0-1723209800448.png

I have 

spark.stop()
at the end of each notebook. And I know they only take a couple of minutes. Why isn't it moving on?

Thanks for sharing!

 

I'm curious why you are using spark.stop()?

 

I'm curious if it is necessary to use it or not.

 

I didn't think it was necessary in Fabric. Did you find any information about it?

DebbieE
Community Champion
Community Champion

It seemed to run quickly this time. Maybe it was just a blip. And I have changed the connections to success ones

frithjof_v
Super User
Super User

Are you running the notebook manually, or inside a data pipeline? If you are running them inside a data pipeline, perhaps you can add a wait activity between them. Perhaps wait 1 or 2 minutes.

 

Microsoft Fabric – Notebook session usage explained (And how to save CU’s or billed time) - FourMoo ...

 

spark.stop() - is it needed? : r/MicrosoftFabric (reddit.com)

 

Are you using Notebook A to trigger Notebook B? Then I think they can share the compute resources. See links below:

Microsoft Spark Utilities (MSSparkUtils) for Fabric - Microsoft Fabric | Microsoft Learn

Using runMultiple To Orchastrate Notebook Execution in Microsoft Fabric

 

 

You could also try out the mssparkutils.session.stop() instead of spark.stop()

I haven't tried it myself.

Helpful resources

Announcements
Fabric July 2025 Monthly Update Carousel

Fabric Monthly Update - July 2025

Check out the July 2025 Fabric update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.