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.
This commit is contained in:
Fabio Manganiello 2022-04-11 00:38:11 +02:00
parent 67ff585f6c
commit f17245e8c7
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -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):