title: ERROR:SparkContext can only be used on the driver, not in code that it run on workers. For more information, see SPARK-5063
body: <p>I am presently working with ASN 1 Decoder.I will be getting a Hex decimal code from producer and i will be collecting it in consumer.
  Then after i will be converting the hex code to RDD and then pass the hex value RDD to another function with in same class Decode_Module and will be using python asn1 decoder to decode the hex data and return it back and print it.
  I don't understand whats wrong with my code.I have already installed my asn1 parser dependencies in worker nodes too.
  Any wrong with the way i call in lambda expression or something else.</p>
  
  <p>My ERROR: Exception: It appears that you are attempting to reference SparkContext from a broadcast variable, action, or transformation. SparkContext can only be used on the driver, not in code that it run on workers. For more information, see SPARK-5063</p>
  
  <p>PLEASE HELP ME THANK YOU</p>
  
  <p><strong>My CODE:</strong></p>
  
  <pre><code>class telco_cn:
  
   def __init__(self,sc):
      self.sc = sc
      print ('in init function')
      logging.info('eneterd into init function')
  
   def decode_module(self,msg):
          try:
              logging.info('Entered into generate module')
              ### Providing input for module we need to load
              load_module(config_values['load_module'])
              ### Providing Value for Type of Decoding
              ASN1.ASN1Obj.CODEC = config_values['PER_DECODER']
              ### Providing Input for Align/UnAlign
              PER.VARIANT = config_values['PER_ALIGNED']
              ### Providing Input for pdu load
              pdu = GLOBAL.TYPE[config_values['pdu_load']]
              ### Providing Hex value to buf
              buf = '{}'.format(msg).decode('hex')
              return val
          except Exception as e:
              logging.debug('error in decode_module function %s' %str(e))
  
  
   def consumer_input(self,sc,k_topic):
              logging.info('entered into consumer input');print(k_topic)
              consumer = KafkaConsumer(ip and other values given)
              consumer.subscribe(k_topic)
              for msg in consumer:
                  print(msg.value);
                  a = sc.parallelize([msg.value])
                  d = a.map(lambda x: self.decode_module(x)).collect()
                  print d
  
  if __name__ == "__main__":
      logging.info('Entered into main')
      conf = SparkConf()
      conf.setAppName('telco_consumer')
      conf.setMaster('yarn-client')
      sc = SparkContext(conf=conf)
      sqlContext = HiveContext(sc)
      cn = telco_cn(sc)
      cn.consumer_input(sc,config_values['kafka_topic'])
  </code></pre>