Question on data binding with Data Grid

I do see the use of anvil.server.session in the snippets above, so there may be a key for a dictionary that keeps the globals for different sessions.

But this would have two problems:

  • Even with persistent server enabled, there are reasons why the server could decide to spin a new instance to respond to the next request, so you can’t rely on the globals being there
  • You would need to design some cleanup to prevent that globals from growing too large and running out of memory, either over time or because you have many clients

Using globals with persistent server may make sense only if building those globals would take a long time, but you should always be ready to rebuild them if they don’t exist because the request is being handled by a new instance. And accesses to those globals should be thread safe, because you could have multiple requests accessing them concurrently.

I never have the slow global problem, so I don’t have globals at all. All my apps have persistent server enabled and none of them sets globals.

1 Like