StreamingQuery.
awaitTermination
Waits for the termination of this query, either by query.stop() or by an exception. If the query has 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.
query.stop()
If the query has terminated, then all subsequent calls to this method will either return immediately (if the query was terminated by stop()), or throw the exception immediately (if the query has terminated with exception).
stop()
throws StreamingQueryException, if this query has terminated with an exception
StreamingQueryException
New in version 2.0.0.
default None. The waiting time for specified streaming query to terminate.
None
The result whether specified streaming query has terminated or not within the timeout seconds if timeout is set. The StreamingQueryException will be thrown if the query has terminated with an exception.
Examples
>>> sdf = spark.readStream.format("rate").load() >>> sq = sdf.writeStream.format('memory').queryName('query_awaitTermination').start()
Return whether the query has terminated or not within 5 seconds
>>> sq.awaitTermination(5) False
>>> sq.stop()