Created
April 27, 2017 16:01
-
-
Save sebastian-nagel/310a5a5f39cc668fb71b6ace208706f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# hanging executor on Spark 2.1.0 and Python 2.7 | |
from pyspark import SparkContext | |
class BadEncodedException(Exception): | |
def __init__(self, reason): | |
self.msg = str(reason) | |
super(BadEncodedException, self).__init__(self.msg) | |
def emit_word(word): | |
if word == 'foo': | |
raise(BadEncodedException('foo <[\x8b\x8e\x8b]>')) | |
return word, 1 | |
sc = SparkContext() | |
rdd = sc.parallelize(['abc', 'foo', 'def']) | |
output = rdd.map(emit_word).reduceByKey(lambda x, y: x + y).collect() | |
for (word, count) in output: | |
print("%s: %i" % (word, count)) | |
sc.stop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment