From f17245e8c7207147e6f63296bf3ed99353df636f Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 11 Apr 2022 00:38:11 +0200 Subject: [PATCH] Send an EntityUpdateEvent only if an entity has already been persisted If an event comes from an entity that hasn't been persisted yet on the internal storage then we wait for the entity record to be committed before firing an event. It's better to wait a couple of seconds for the database to synchronize rather than dealing with entity events with incomplete objects. --- platypush/entities/_engine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platypush/entities/_engine.py b/platypush/entities/_engine.py index bbb0bb6c9..f82c70297 100644 --- a/platypush/entities/_engine.py +++ b/platypush/entities/_engine.py @@ -113,7 +113,7 @@ class EntitiesEngine(Thread): self.logger.info('Entities cache initialized') def _process_event(self, entity: Entity): - if self._entity_has_changes(entity): + if self._entity_has_changes(entity) and entity.id: get_bus().post(EntityUpdateEvent(entity=entity)) def post(self, *entities: Entity):