在分配python错误之前引用了本地变量'retry_rdd'
我尝试将其引用为全局变量,但仍给出了名称 未定义的错误。
def send_message(self, df):
#global retry_rdd
try:
results_rdd.cache()
logger.info("Count of the list in rdd = " + str(results_rdd.count()))
error_rdd = results_rdd.filter(lambda x: '(numbers_sent,messages_sent)' not in x)
logger.info(error_rdd.count())
retry_rdd = error_rdd.mapPartitions(
lambda part: self.retrySend_msg(part, config, token))
retry_rdd.cache()
except Exception as e:
logger.error("Error occurred while sending to dest.")
logger.error(e)
if retry_rdd and retry_rdd.count() > 0:
error_archive = '{}/{}/'.format(self.config['error']['process'], self.get_time())
logger.info("Saving errors to archive: {}".format(error_archive))
retry_rdd.saveAsTextFile(error_archive)