cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Unregistering / Removing A SparkListener

Scorpius
New Contributor II

Hey,

So currently I'm using Pyspark and utilizing SparkListener to track metrics of my spark jobs. The problem I can't seem to solve is why in databricks the listener cannot be removed with removeSparkListener as it still is attached to the context.

# Func--
def unregister(spark_context: SparkContext, *listeners: SparkListener):
    for listener in listeners:
      spark_context._jsc.sc().removeSparkListener(listener)
    #spark_context._gateway.shutdown_callback_server()
 
 
 
 
 
# Single--
sc._jsc.sc().removeSparkListener(listener) # Where SC is the SparkContext

2 REPLIES 2

Kaniz
Community Manager
Community Manager

Hi @CJ Wโ€‹, Please go through this GitHub link which resolves this patch:-

Please let us know if it helps you in any way.

Scorpius
New Contributor II

Thanks for the reply!

Although in practice this should work, but it doesn't work if it's running in Databricks. Is there any other readings you can provide?

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.