-
Notifications
You must be signed in to change notification settings - Fork 24
Query iterator only throws exeption once #252
Query iterator only throws exeption once #252
Conversation
value = self._stream.fetch(self._request_id) | ||
return value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inline var
elif response.is_done() and response.error is None: | ||
raise TypeDBClientException.of(TRANSACTION_CLOSED) | ||
elif response.is_done() and response.error is not None: | ||
raise TypeDBClientException.of_rpc(response.error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go back to the old behaviour of retrieving the error from the Done
message stored in the queue, which will be thrown exactly once. After that, this queue will always throw transaction closed
.
raise TypeDBClientException.of(ILLEGAL_STATE) | ||
|
||
def __next__(self) -> transaction_proto.Transaction.ResPart: | ||
if self._bidirectional_stream.get_error() is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the error will come from the backing Queue
, rather than the bidirectional stream.
@flyingsilverfin lol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems identical to the Java client PR 👍
What is the goal of this PR?
Revert previous changes from #247 and #248, which made query queues and iterators throw the same error idempotently. However, this goes counter to standard usage of iterators and queues, which are not meant to behave idempotently (each item is only returned once, and if they have an error they should no longer be used).
What are the changes implemented in this PR?
Note: mirrors change from typedb/typedb-driver#372