amqpy
amqpy copied to clipboard
Connection.last_heartbeat_recv is timezone naive
When trying to detect connection failures on a connection, an application can look at the last_heartbeat_recv datetime(which comes from the underlying transport object) to determine if rabbitmq is still in communication. However, the object is timezone naive and when checking this object during DST transitions(on systems without DST disabled), there is no reliable way to determine how old the timestamp is.
Would it break any code if instead of
self.last_heartbeat_received = datetime.datetime.now()
it was changed to
self.last_heartbeat_received = datetime.datetime.now(tz=datetime.timezone.utc)
Presumably the last_heartbeat_sent date should also be in UTC as well.