xinrong-databricks commented on code in PR #36086:
URL: https://github.com/apache/spark/pull/36086#discussion_r844218251


##########
python/pyspark/sql/streaming/query.py:
##########
@@ -309,11 +309,22 @@ def addListener(self, listener: StreamingQueryListener) 
-> None:
         java_import(gw.jvm, "org.apache.spark.sql.streaming.*")
         ensure_callback_server_started(gw)
 
-        self._jsqm.addListener(
+        jlistener = (
             SparkContext._jvm.PythonStreamingQueryListenerWrapper(  # type: 
ignore[union-attr]
                 JStreamingQueryListener(listener)
             )
         )
+        listener._set_jlistener(jlistener)
+        self._jsqm.addListener(jlistener)
+
+    def removeListener(self, listener: StreamingQueryListener) -> None:
+        """
+        Deregister a :class:`StreamingQueryListener`.
+
+        .. versionadded:: 3.4.0
+        """
+        if hasattr(listener, "_jlistener"):

Review Comment:
   Out of curiosity, why don't we update the `_jlistener` attribute?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to