Skip to content
Snippets Groups Projects
Commit 317a9eb1 authored by Ewen Cheslack-Postava's avatar Ewen Cheslack-Postava
Browse files

Pass self to SparkContext._ensure_initialized.

The constructor for SparkContext should pass in self so that we track
the current context and produce errors if another one is created. Add
a doctest to make sure creating multiple contexts triggers the
exception.
parent 56d230e6
No related branches found
No related tags found
No related merge requests found
......@@ -67,8 +67,17 @@ class SparkContext(object):
@param batchSize: The number of Python objects represented as a single
Java object. Set 1 to disable batching or -1 to use an
unlimited batch size.
>>> from pyspark.context import SparkContext
>>> sc = SparkContext('local', 'test')
>>> sc2 = SparkContext('local', 'test2') # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ValueError:...
"""
SparkContext._ensure_initialized()
SparkContext._ensure_initialized(self)
self.master = master
self.jobName = jobName
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment