pyspark.SparkContext.getOrCreate#

classmethod SparkContext.getOrCreate(conf=None)[source]#

Get or instantiate a SparkContext and register it as a singleton object.

New in version 1.4.0.

Parameters
confSparkConf, optional

SparkConf that will be used for initialization of the SparkContext.

Returns
SparkContext

current SparkContext, or a new one if it wasn’t created before the function call.

Examples

>>> SparkContext.getOrCreate()
<SparkContext ...>