Environment: python 3.8.4 under Windows 10.
I am trying to write avro from dictionary.
Dictionary contains timestamp
def get_dict(self):
return {"msg_header": {...
"msg_timestamp": int(datetime.datetime.timestamp(datetime.datetime.now())),
...},
...
}
Avro schema:
{
"name" : "msg_timestamp",
"type" : {
"type" : "long",
"logicalType" : "timestamp-millis"
}
Writing Avro:
writer = avro.io.DatumWriter(schema)
bytes_writer = io.BytesIO()
encoder = avro.io.BinaryEncoder(bytes_writer)
writer.write(get_dict(), encoder) #----------Exception here
raw_bytes = bytes_writer.getvalue()
Exception:
... line 581, in write_timestamp_millis_long datum = datum.astimezone(tz=timezones.utc) AttributeError: 'int' object has no attribute 'astimezone'
Any ideas how to fix it? I do not want conversion to UTC. Even if I set system TZ to UTC, it does not help, method astimezone(tz=timezones.utc) is being executed causing exception