[
https://issues.apache.org/jira/browse/AVRO-2591?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Michael A. Smith reassigned AVRO-2591:
--------------------------------------
Assignee: Michael A. Smith
> Getting error when reading avro message python
> ----------------------------------------------
>
> Key: AVRO-2591
> URL: https://issues.apache.org/jira/browse/AVRO-2591
> Project: Apache Avro
> Issue Type: Bug
> Components: python
> Affects Versions: 1.9.1
> Environment: Windows
> Reporter: Alperen Koksel
> Assignee: Michael A. Smith
> Priority: Major
>
> I can't read avro messages in python in windows environment.
> We 're using avro templates on kafka. I get the avro serialized message using
> kafkaconsumer but I can't deserialize using avro.io.
>
> {code:java}
> // code placeholder
> schema_path = "x.avsc"
> schema = avro.schema.Parse(open(schema_path).read())
> def from_avro(msg):
> bytes_reader = io.BytesIO(msg)
> decoder = avro.io.BinaryDecoder(bytes_reader)
> reader = avro.io.DatumReader(schema, schema)
> user1 = reader.read(decoder)
> return user1
> consumer = KafkaConsumer('avro_topic',
> bootstrap_servers=['0.dual.kafka.qa-us.com:9092',
> '1.dual.kafka.qa-us.com:9092',
> '2.dual.kafka.qa-us.com:9092'],
> auto_offset_reset='earliest',
> group_id='my_group',
> value_deserializer=from_avro
> )
> for msg in consumer:
> print(msg){code}
>
> {code:java}
> // code placeholder
> File
> "C:\Users\alpl\PycharmProjects\WorkOn\venv\lib\site-packages\avro\io.py",
> line 240, in read_bytes
> assert (nbytes >= 0), nbytes
> AssertionError: -45
> {code}
>
> I found following stackoverflow post which posted more than a year ago.
> [https://stackoverflow.com/questions/50106662/error-reading-avro-file-in-python/58336209#58336209]
> I tried several versions of avro. Results are same.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)