From 973bf87e67449a2dd50560a870ade6a54d2d7f73 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 18 Aug 2022 11:27:12 -0400 Subject: [PATCH] Don't log aboout unknown status msg if no oid --- piker/clearing/_ems.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/piker/clearing/_ems.py b/piker/clearing/_ems.py index 542b7c4d..ae54615b 100644 --- a/piker/clearing/_ems.py +++ b/piker/clearing/_ems.py @@ -728,7 +728,6 @@ async def translate_and_relay_brokerd_events( # msg-chain/dialog. ems_client_order_stream = router.dialogues[oid] status_msg = book._active[oid] - old_resp = status_msg.resp status_msg.resp = status # retrieve existing live flow @@ -736,7 +735,8 @@ async def translate_and_relay_brokerd_events( if old_reqid and old_reqid != reqid: log.warning( f'Brokerd order id change for {oid}:\n' - f'{old_reqid} -> {reqid}' + f'{old_reqid}:{type(old_reqid)} ->' + f' {reqid}{type(reqid)}' ) status_msg.reqid = reqid # THIS LINE IS CRITICAL! @@ -856,12 +856,16 @@ async def translate_and_relay_brokerd_events( 'status': status, 'reqid': reqid, }: - status_msg = book._active[oid] - log.warning( - 'Unhandled broker status for dialog:\n' - f'{pformat(status_msg)}\n' - f'{pformat(brokerd_msg)}\n' - ) + oid = book._ems2brokerd_ids.inverse.get(reqid) + msg = f'Unhandled broker status for dialog {reqid}:\n' + if oid: + status_msg = book._active[oid] + msg += ( + f'last status msg: {pformat(status_msg)}\n\n' + f'this msg:{pformat(brokerd_msg)}\n' + ) + + log.warning(msg) case _: raise ValueError(f'Brokerd message {brokerd_msg} is invalid')