From c40c0eff4847d876e2b68d99befc8242df41db32 Mon Sep 17 00:00:00 2001 From: giwa Date: Sun, 3 Aug 2014 22:05:28 -0700 Subject: [PATCH] added stop in StreamingContext --- python/pyspark/streaming/context.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/python/pyspark/streaming/context.py b/python/pyspark/streaming/context.py index 5952e81a4bef3..01201f66421f8 100644 --- a/python/pyspark/streaming/context.py +++ b/python/pyspark/streaming/context.py @@ -121,3 +121,15 @@ def textFileStream(self, directory): file system. FIle names starting with . are ignored. """ return DStream(self._jssc.textFileStream(directory), self, UTF8Deserializer()) + + def stop(self, stopSparkContext=True): + """ + Stop the execution of the streams immediately (does not wait for all received data + to be processed). + """ + + try: + self._jssc.stop(stopSparkContext) + finally: + # Stop Callback server + SparkContext._gateway.shutdown()