Skip to content

Commit

Permalink
handle code review 2
Browse files Browse the repository at this point in the history
1. remove exception of socket.error for keeping tracking of error outside

2. refactor for better readability
  • Loading branch information
Ai He committed Jun 29, 2015
1 parent e75c5c8 commit d4fc9c4
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions python/pyspark/rdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,14 @@ def _load_from_socket(port, serializer):
sock = None
continue
break
if sock:
try:
rf = sock.makefile("rb", 65536)
for item in serializer.load_stream(rf):
yield item
except socket.error:
raise Exception("encounter error when connecting to socket server")
finally:
sock.close()
else:
if not sock:
raise Exception("could not open socket")
try:
rf = sock.makefile("rb", 65536)
for item in serializer.load_stream(rf):
yield item
finally:
sock.close()


def ignore_unicode_prefix(f):
Expand Down

0 comments on commit d4fc9c4

Please sign in to comment.