Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
squito committed Dec 17, 2018
1 parent c891464 commit 7b2d223
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
11 changes: 6 additions & 5 deletions python/pyspark/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,14 @@ def __init__(self, master=None, appName=None, sparkHome=None, pyFiles=None,
ValueError:...
"""
self._callsite = first_spark_call() or CallSite(None, None, None)
if gateway != None and gateway.gateway_parameters.auth_token == None:
if gateway is not None and gateway.gateway_parameters.auth_token is None:
if conf and conf.get("spark.python.allowInsecurePy4j", "false") == "true":
print("****BAM****")
warnings.warn("You are passing in an insecure py4j gateway. This "
"presents a security risk, and will be completely forbidden in Spark 3.0")
warnings.warn(
"You are passing in an insecure py4j gateway. This "
"presents a security risk, and will be completely forbidden in Spark 3.0")
else:
raise Exception("You are trying to pass an insecure py4j gateway to spark. This"
raise Exception(
"You are trying to pass an insecure py4j gateway to spark. This"
" presents a security risk. If you are sure you understand and accept this"
" risk, you can add the conf 'spark.python.allowInsecurePy4j=true', but"
" note this option will be removed in Spark 3.0")
Expand Down
3 changes: 2 additions & 1 deletion python/pyspark/java_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def launch_gateway(conf=None):
"""
return _launch_gateway(conf)


def _launch_gateway(conf=None, insecure=False):
"""
launch jvm gateway
Expand Down Expand Up @@ -130,7 +131,7 @@ def killChild():
# Connect to the gateway
gateway_params = GatewayParameters(port=gateway_port, auto_convert=True)
if not insecure:
gateway_params.auth_token=gateway_secret
gateway_params.auth_token = gateway_secret
gateway = JavaGateway(gateway_parameters=gateway_params)

# Import the classes used by PySpark
Expand Down
4 changes: 3 additions & 1 deletion python/pyspark/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2403,9 +2403,11 @@ def test_allow_insecure_gateway_with_conf(self):
with SparkContext(conf=conf, gateway=gateway) as sc:
print("sc created, about to create accum")
a = sc.accumulator(1)
rdd = sc.parallelize([1,2,3])
rdd = sc.parallelize([1, 2, 3])

def f(x):
a.add(x)

rdd.foreach(f)
self.assertEqual(7, a.value)
print("exiting allow insecure test")
Expand Down

0 comments on commit 7b2d223

Please sign in to comment.