def get_spark_context(conf=None):
if hasattr(SparkContext, "<STR_LIT>"):<EOL><INDENT>with SparkContext._lock:<EOL><INDENT>if SparkContext._active_spark_context is None:<EOL><INDENT>spark_conf = create_spark_conf() if conf is None else conf<EOL>return SparkContext.getOrCreate(spark_conf)<EOL><DEDENT>else:<EOL><INDENT>return SparkContext.getOrCreate()<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if SparkContext._active_spark_context is None:<EOL><INDENT>spark_conf = create_spark_conf() if conf is None else conf<EOL>return SparkContext(conf=spark_conf)<EOL><DEDENT>else:<EOL><INDENT>return SparkContext._active_spark_context<EOL><DEDENT><DEDENT>
Get the current active spark context and create one if no active instance
:param conf: combining bigdl configs into spark conf
:return: SparkContext