class_docstr: A class to manage all the :class:`StreamingQuery` StreamingQueries active.
  
  .. versionadded:: 2.0.0
  
  .. versionchanged:: 3.5.0
      Supports Spark Connect.
  
  Notes
  -----
  This API is evolving.
docstr: Wait until any of the queries on the associated SparkSession has terminated since the
  creation of the context, or since :func:`resetTerminated()` was called. If any query was
  terminated with an exception, then the exception will be thrown.
  If `timeout` is set, it returns whether the query has terminated or not within the
  `timeout` seconds.
  
  If a query has terminated, then subsequent calls to :func:`awaitAnyTermination()` will
  either return immediately (if the query was terminated by :func:`query.stop()`),
  or throw the exception immediately (if the query was terminated with exception). Use
  :func:`resetTerminated()` to clear past terminations and wait for new terminations.
  
  In the case where multiple queries have terminated since :func:`resetTermination()`
  was called, if any query has terminated with exception, then :func:`awaitAnyTermination()`
  will throw any of the exception. For correctly documenting exceptions across multiple
  queries, users need to stop all of them after any of them terminates with exception, and
  then check the `query.exception()` for each query.
  
  throws :class:`StreamingQueryException`, if `this` query has terminated with an exception
  
  .. versionadded:: 2.0.0
  
  .. versionchanged:: 3.5.0
      Supports Spark Connect.
  
  Parameters
  ----------
  timeout : int, optional
      default ``None``. The waiting time for any streaming query to terminate.
  
  Returns
  -------
  bool, optional
      The result whether any streaming query has terminated or not within the `timeout`
      seconds if `timeout` is set. The :class:`StreamingQueryException` will be thrown if any
      query has terminated with an exception.
  
  Examples
  --------
  >>> sdf = spark.readStream.format("rate").load()
  >>> sq = sdf.writeStream.format('memory').queryName('this_query').start()
  
  Return whether any of the query on the associated SparkSession
  has terminated or not within 5 seconds
  
  >>> spark.streams.awaitAnyTermination(5)
  True
  >>> sq.stop()
docstr_tok: ["Wait","until","any","of","the","queries","on","the","associated","SparkSession","has","terminated","since","the","creation","of","the","context",",","or","since",":","func",":","`","resetTerminated","(",")","`","was","called",".","If","any","query","was","terminated","with","an","exception",",","then","the","exception","will","be","thrown",".","If","`","timeout","`","is","set",",","it","returns","whether","the","query","has","terminated","or","not","within","the","`","timeout","`","seconds",".","If","a","query","has","terminated",",","then","subsequent","calls","to",":","func",":","`","awaitAnyTermination","(",")","`","will","either","return","immediately","(","if","the","query","was","terminated","by",":","func",":","`","query.stop","(",")","`",")",",","or","throw","the","exception","immediately","(","if","the","query","was","terminated","with","exception",")",".","Use",":","func",":","`","resetTerminated","(",")","`","to","clear","past","terminations","and","wait","for","new","terminations",".","In","the","case","where","multiple","queries","have","terminated","since",":","func",":","`","resetTermination","(",")","`","was","called",",","if","any","query","has","terminated","with","exception",",","then",":","func",":","`","awaitAnyTermination","(",")","`","will","throw","any","of","the","exception",".","For","correctly","documenting","exceptions","across","multiple","queries",",","users","need","to","stop","all","of","them","after","any","of","them","terminates","with","exception",",","and","then","check","the","`","query.exception","(",")","`","for","each","query",".","throws",":","class",":","`","StreamingQueryException","`",",","if","`","this","`","query","has","terminated","with","an","exception","..","versionadded",":",":","2.0.0","..","versionchanged",":",":","3.5.0","Supports","Spark","Connect",".","Parameters","--","--","--","--","--","timeout",":","int",",","optional","default","``","None","``",".","The","waiting","time","for","any","streaming","query","to","terminate",".","Returns","--","--","--","-","bool",",","optional","The","result","whether","any","streaming","query","has","terminated","or","not","within","the","`","timeout","`","seconds","if","`","timeout","`","is","set",".","The",":","class",":","`","StreamingQueryException","`","will","be","thrown","if","any","query","has","terminated","with","an","exception",".","Examples","--","--","--","--",">",">",">","sdf","=","spark.readStream.format","(","``","rate","''",")",".load","(",")",">",">",">","sq","=","sdf.writeStream.format","(","'memory","'",")",".queryName","(","'this_query","'",")",".start","(",")","Return","whether","any","of","the","query","on","the","associated","SparkSession","has","terminated","or","not","within","5","seconds",">",">",">","spark.streams.awaitAnyTermination","(","5",")","True",">",">",">","sq.stop","(",")"]
code: def awaitAnyTermination(
      self, timeout: Optional[int] = None
  ) -> Optional[bool]:
      """
      Wait until any of the queries on the associated SparkSession has terminated since the
      creation of the context, or since :func:`resetTerminated()` was called. If any query was
      terminated with an exception, then the exception will be thrown.
      If `timeout` is set, it returns whether the query has terminated or not within the
      `timeout` seconds.
  
      If a query has terminated, then subsequent calls to :func:`awaitAnyTermination()` will
      either return immediately (if the query was terminated by :func:`query.stop()`),
      or throw the exception immediately (if the query was terminated with exception). Use
      :func:`resetTerminated()` to clear past terminations and wait for new terminations.
  
      In the case where multiple queries have terminated since :func:`resetTermination()`
      was called, if any query has terminated with exception, then :func:`awaitAnyTermination()`
      will throw any of the exception. For correctly documenting exceptions across multiple
      queries, users need to stop all of them after any of them terminates with exception, and
      then check the `query.exception()` for each query.
  
      throws :class:`StreamingQueryException`, if `this` query has terminated with an exception
  
      .. versionadded:: 2.0.0
  
      .. versionchanged:: 3.5.0
          Supports Spark Connect.
  
      Parameters
      ----------
      timeout : int, optional
          default ``None``. The waiting time for any streaming query to terminate.
  
      Returns
      -------
      bool, optional
          The result whether any streaming query has terminated or not within the `timeout`
          seconds if `timeout` is set. The :class:`StreamingQueryException` will be thrown if any
          query has terminated with an exception.
  
      Examples
      --------
      >>> sdf = spark.readStream.format("rate").load()
      >>> sq = sdf.writeStream.format('memory').queryName('this_query').start()
  
      Return whether any of the query on the associated SparkSession
      has terminated or not within 5 seconds
  
      >>> spark.streams.awaitAnyTermination(5)
      True
      >>> sq.stop()
      """
      if timeout is not None:
          if not isinstance(timeout, (int, float)) or timeout < 0:
              raise PySparkValueError(
                  error_class="VALUE_NOT_POSITIVE",
                  message_parameters={
                      "arg_name": "timeout",
                      "arg_value": type(timeout).__name__,
                  },
              )
          return self._jsqm.awaitAnyTermination(int(timeout * 1000))
      else:
          return self._jsqm.awaitAnyTermination()
  
imports: import json
  from typing import Any, Dict, List, Optional
  from py4j.java_gateway import JavaObject, java_import
  from pyspark.errors import StreamingQueryException, PySparkValueError
  from pyspark.errors.exceptions.captured import StreamingQueryException
  from pyspark.sql.streaming.listener import StreamingQueryListener
label_desc: Use image node_id 4 for calling the StreamingQueryManager obj's underlying member method code with example usage: obj.awaitAnyTermination(timeout) and returns: self, self