python-fints
python-fints copied to clipboard
Exception handling in dialog.send()
From dialog.py:
# assert response.segments[0].message_number == self.next_message_number[response.DIRECTION]
# FIXME Better handling of HKEND in exception case
self.messages[response.DIRECTION][response.segments[0].message_number] = response
self.next_message_number[response.DIRECTION] += 1
From @henryk in PR #34:
The one in dialog.py:send() is more of a note to self. Previously the assert was a sanity check on received/expected message sequence numbers (and prevents message processing out of order). However, an exception during processing would exit the context handler, would close the dialog, would send() a HKEND message, which would then seem out of order. I'm not sure how to properly[tm] address it: Find the right invariant that is reentrancy safe, or ignore HKEND messages, or skip checks in exception context, or something else.