Speed up serializing event messages (#100017)

This commit is contained in:
J. Nick Koston 2023-09-10 08:25:13 -05:00 committed by GitHub
parent e4af50f955
commit ad4619c038
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -94,7 +94,9 @@ def _cached_event_message(event: Event) -> str:
The IDEN_TEMPLATE is used which will be replaced
with the actual iden in cached_event_message
"""
return message_to_json({"id": IDEN_TEMPLATE, "type": "event", "event": event})
return message_to_json(
{"id": IDEN_TEMPLATE, "type": "event", "event": event.as_dict()}
)
def cached_state_diff_message(iden: int, event: Event) -> str:

View File

@ -953,7 +953,7 @@ class Event:
{
"event_type": self.event_type,
"data": ReadOnlyDict(self.data),
"origin": str(self.origin.value),
"origin": self.origin.value,
"time_fired": self.time_fired.isoformat(),
"context": self.context.as_dict(),
}