Skip to content

Connection.last_heartbeat_recv is timezone naive #36

@kundertk

Description

@kundertk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions