Unfortunately, global
variables aren’t safe to use in Dash for a couple of reasons:
1 - Mutations of global variable will persist across sessions causing one user’s session to influence the next user’s session.
2 - The global variable mutations will not persist across python processes. It is necessary to run Dash across multiple processes (with something like gunicorn
) in production environments so that Dash can handle more than 1 request at once.
However, there are a couple of workarounds for this workflow. See Working on large datasets -- comparison with shiny for more details