Add event type into msg dict

flexxin
Tyler Goodlet 2022-06-04 13:44:12 -04:00
parent 41f24f3de6
commit 827b5f9c45
1 changed files with 11 additions and 4 deletions

View File

@ -780,23 +780,29 @@ class Client:
) -> None: ) -> None:
log.error(errorString)
reason = errorString reason = errorString
if reqId == -1: if reqId == -1:
# it's a general event? # it's a general event?
key = 'event' key = 'event'
log.info(errorString)
else: else:
key = 'error' key = 'error'
log.error(errorString)
try: try:
to_trio.send_nowait(( to_trio.send_nowait((
key, key,
# error "object" # error "object"
{'reqid': reqId, {
'type': key,
'reqid': reqId,
'reason': reason, 'reason': reason,
'contract': contract} 'error_code': errorCode,
'contract': contract,
}
)) ))
except trio.BrokenResourceError: except trio.BrokenResourceError:
# XXX: eventkit's ``Event.emit()`` for whatever redic # XXX: eventkit's ``Event.emit()`` for whatever redic
@ -2248,6 +2254,7 @@ async def trades_dialogue(
recv_trade_updates, recv_trade_updates,
client=client, client=client,
) as (first, trade_event_stream): ) as (first, trade_event_stream):
task_status.started(trade_event_stream) task_status.started(trade_event_stream)
await trio.sleep_forever() await trio.sleep_forever()