Skip to content

Commit 8be5204

Browse files
authored
Merge pull request #3 from YinYin-blip/streamingapi
Streamingapi
2 parents dd6ef14 + 546298b commit 8be5204

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

examples/stream.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ def handle_update(pair, state, update):
88
if update is not None:
99
print(update)
1010

11-
asyncio.get_event_loop().run_until_complete(
12-
stream_market(
11+
async def main():
12+
await stream_market(
1313
pair="XBTZAR",
1414
api_key_id="", # API Key goes here
1515
api_key_secret="", # and API Secret goes here
1616
update_callback=handle_update,
1717
)
18-
)
18+
19+
20+
if __name__ == "__main__":
21+
asyncio.run(main())

luno_python/stream_client.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ async def stream_market(
198198
})
199199
await websocket.send(auth)
200200

201-
await asyncio.gather(
202-
_read_from_websocket(websocket, p, update_callback),
203-
_write_keep_alive(websocket),
204-
)
201+
async with asyncio.TaskGroup() as tg:
202+
tg.create_task(_read_from_websocket(websocket, p, update_callback))
203+
tg.create_task(_write_keep_alive(websocket))

0 commit comments

Comments
 (0)