I have a background task which sets fields of its task_state at various points in its process.
Having just discovered that task_state has the “update” method I’ve realised that I could redesign the task to make just one call to update its state rather than set ~6 fields in different lines of code, i.e. I could replace:
anvil.server.task_state[“field_1”] = “A”
anvil.server.task_state[“field_2”] = “B”
anvil.server.task_state[“field_3”] = “C”
etc
with anvil.server.task_state.update(field_1=“A”, field_2=“B”, field_3=“C” etc)
My question is: is there any value (other than perhaps code clarity) to making this change? Is setting task_state writing to a data table somewhere and hence somewhat expensive? Or would this be a pointless change?
(My app has high usage and has issues with large numbers of calls to data tables)
Thanks!