Skip to content

Commit

Permalink
test exc
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaakola-aiven committed Jul 24, 2024
1 parent a226610 commit 6113f87
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions karapace/protobuf/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,13 @@ def writer_process(
# Writing happens in the forked process, catch is broad so exception will get communicated
# back to calling process.
except Exception as bare_exception: # pylint: disable=broad-exception-caught
try:
raise ProtobufTypeException(writer_schema, datum) from bare_exception
except ProtobufTypeException as protobuf_exception:
writer_queue.put(protobuf_exception)
raise protobuf_exception
except BaseException as base_exception: # pylint: disable=broad-exception-caught
writer_queue.put(base_exception)
#try:
# raise ProtobufTypeException(writer_schema, datum) from bare_exception
#except ProtobufTypeException as protobuf_exception:
# writer_queue.put(protobuf_exception)
# raise protobuf_exception
writer_queue.put(bare_exception)
raise bare_exception
writer_queue.put(class_instance.SerializeToString())


Expand Down Expand Up @@ -319,4 +319,7 @@ def write_index(self, writer: BytesIO) -> None:
write_indexes(writer, [self._message_index])

def write(self, datum: dict[object, object], writer: BytesIO) -> None:
writer.write(write_in_forked_process(self.config, self._writer_schema, self._message_name, datum))
try:
writer.write(write_in_forked_process(self.config, self._writer_schema, self._message_name, datum))
except BaseException as bare_exception:
raise ProtobufTypeException(self._writer_schema, datum) from bare_exception

0 comments on commit 6113f87

Please sign in to comment.