amqpy icon indicating copy to clipboard operation
amqpy copied to clipboard

Connection.last_heartbeat_recv is timezone naive

Open kundertk opened this issue 6 years ago • 0 comments

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.

kundertk avatar Mar 14 '18 22:03 kundertk