Skip to content

Commit

Permalink
Fix hanging in 2.7 due to using codecs.getreader instead of io.open.
Browse files Browse the repository at this point in the history
Don't know for sure why it was hanging before, but it doesn't if you use
io.open, and that's more consistent with Python 3 anyway.
  • Loading branch information
dan-blanchard committed Jun 23, 2015
1 parent 5feb633 commit dd37a29
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions streamparse/storm/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,9 @@ def _wrap_stream(stream):
return io.TextIOWrapper(stream.buffer, encoding='utf-8')
elif hasattr(stream, 'readable'):
return io.TextIOWrapper(stream, encoding='utf-8')
# Python 2.x stdin and stdout are just files, so use codecs module
elif 'r' in stream.mode:
return codecs.getreader('utf-8')(stream)
# Python 2.x stdin and stdout are just files
else:
return codecs.getwriter('utf-8')(stream)
return io.open(stream.fileno(), mode=stream.mode, encoding='utf-8')

def _setup_component(self, storm_conf, context):
"""Add helpful instance variables to component after initial handshake
Expand Down Expand Up @@ -417,11 +415,9 @@ def emit(self, tup, tup_id=None, stream=None, anchors=None,
:param stream: the ID of the stream to emit this tuple to. Specify
``None`` to emit to default stream.
:type stream: str
:param anchors: IDs the tuples (or :class:`streamparse.storm.component.Tuple`
instances) which the emitted tuples should be anchored
to. If ``auto_anchor`` is set to ``True`` and
you have not specified ``anchors``, ``anchors`` will be
set to the incoming/most recent tuple ID(s). This is
:param anchors: IDs the tuples (or
:class:`streamparse.storm.component.Tuple` instances)
which the emitted tuples should be anchored to. This is
only passed by :class:`streamparse.storm.bolt.Bolt`.
:type anchors: list
:param direct_task: the task to send the tuple to.
Expand Down

0 comments on commit dd37a29

Please sign in to comment.