def __init__(self, sc=None, value=None, pickle_registry=None, path=None,
                 sock_file=None):
        """
        Should not be called directly by users -- use L{SparkContext.broadcast()}
        instead.
        """
        if sc is not None:
            # we're on the driver.  We want the pickled data to end up in a file (maybe encrypted)
            f = NamedTemporaryFile(delete=False, dir=sc._temp_dir)
            self._path = f.name
            self._sc = sc
            self._python_broadcast = sc._jvm.PythonRDD.setupBroadcast(self._path)
            if sc._encryption_enabled:
                # with encryption, we ask the jvm to do the encryption for us, we send it data
                # over a socket
                port, auth_secret = self._python_broadcast.setupEncryptionServer()
                (encryption_sock_file, _) = local_connect_and_auth(port, auth_secret)
                broadcast_out = ChunkedStream(encryption_sock_file, 8192)
            else:
                # no encryption, we can just write pickled data directly to the file from python
                broadcast_out = f
            self.dump(value, broadcast_out)
            if sc._encryption_enabled:
                self._python_broadcast.waitTillDataReceived()
            self._jbroadcast = sc._jsc.broadcast(self._python_broadcast)
            self._pickle_registry = pickle_registry
        else:
            # we're on an executor
            self._jbroadcast = None
            self._sc = None
            self._python_broadcast = None
            if sock_file is not None:
                # the jvm is doing decryption for us.  Read the value
                # immediately from the sock_file
                self._value = self.load(sock_file)
            else:
                # the jvm just dumps the pickled data in path -- we'll unpickle lazily when
                # the value is requested
                assert(path is not None)
                self._path = path
def __init__ ( self , sc = None , value = None , pickle_registry = None , path = None , sock_file = None ) : if sc is not None : f = NamedTemporaryFile ( delete = False , dir = sc . _temp_dir ) self . _path = f . name self . _sc = sc self . _python_broadcast = sc . _jvm . PythonRDD . setupBroadcast ( self . _path ) if sc . _encryption_enabled : port , auth_secret = self . _python_broadcast . setupEncryptionServer ( ) ( encryption_sock_file , _ ) = local_connect_and_auth ( port , auth_secret ) broadcast_out = ChunkedStream ( encryption_sock_file , 8192 ) else : broadcast_out = f self . dump ( value , broadcast_out ) if sc . _encryption_enabled : self . _python_broadcast . waitTillDataReceived ( ) self . _jbroadcast = sc . _jsc . broadcast ( self . _python_broadcast ) self . _pickle_registry = pickle_registry else : self . _jbroadcast = None self . _sc = None self . _python_broadcast = None if sock_file is not None : self . _value = self . load ( sock_file ) else : assert ( path is not None ) self . _path = path
Should not be called directly by users -- use L{SparkContext.broadcast()}
        instead.