Skip to content

Commit

Permalink
Merge pull request #42 from Devination/patch-1
Browse files Browse the repository at this point in the history
Fixed JSON str vs bytes error:
  • Loading branch information
ttt733 authored Dec 5, 2018
2 parents 1e376a0 + c9ca8cb commit be87d4c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions alpaca_trade_api/stream2.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ async def _connect(self):
}
}))
r = await ws.recv()
if isinstance(r, bytes):
r = r.decode('utf-8')
msg = json.loads(r)
# TODO: check unauthorized
self._ws = ws
Expand All @@ -40,6 +42,8 @@ async def _consume_msg(self):
try:
while True:
r = await ws.recv()
if isinstance(r, bytes):
r = r.decode('utf-8')
msg = json.loads(r)
stream = msg.get('stream')
if stream is not None:
Expand Down

0 comments on commit be87d4c

Please sign in to comment.