forked from platypush/platypush
[#341] Improvements on procedures.save
.
- Update the cached representation of the procedure asynchronously on the `publish_entities` callback. This prevents stale records from being loaded from the db before the entities engine has persisted the new ones. - Don't re-publish all entities when calling `procedures.status` at the end of `procedures.save`. This is both for performance reasons and to avoid sending to the entities engine stale representation of the data.
This commit is contained in:
parent
90a953b738
commit
26f491025a
1 changed files with 8 additions and 4 deletions
|
@ -190,6 +190,9 @@ class ProceduresPlugin(RunnablePlugin, ProcedureEntityManager):
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _on_entity_saved(*_, **__):
|
||||||
|
self._all_procedures[name] = proc_args
|
||||||
|
|
||||||
with self._status_lock:
|
with self._status_lock:
|
||||||
with self._db_session() as session:
|
with self._db_session() as session:
|
||||||
if old_name and old_name != name:
|
if old_name and old_name != name:
|
||||||
|
@ -202,11 +205,12 @@ class ProceduresPlugin(RunnablePlugin, ProcedureEntityManager):
|
||||||
e,
|
e,
|
||||||
)
|
)
|
||||||
|
|
||||||
self._all_procedures[name] = proc_args
|
self.publish_entities(
|
||||||
|
[_ProcedureWrapper(name=name, obj=proc_args)],
|
||||||
|
callback=_on_entity_saved,
|
||||||
|
)
|
||||||
|
|
||||||
self.publish_entities([_ProcedureWrapper(name=name, obj=proc_args)])
|
return self.status(publish=False)
|
||||||
|
|
||||||
return self.status()
|
|
||||||
|
|
||||||
@action
|
@action
|
||||||
def delete(self, name: str):
|
def delete(self, name: str):
|
||||||
|
|
Loading…
Reference in a new issue