Global variables sharing with mutex

This isn’t how Dash works. When you launch a Dash app, there will be a single Python process which handles all callbacks from all users – no sub-processes are created. This means that all of your callbacks share the same memory. So if one user were to trigger a callback that changed a global variable, every other request from any user would then make use of the changed global. So your callbacks have to treat the data structures as being immutable.

While this may seem annoying, as @chriddyp mentioned, it is this design decision that allows Dash to scale to a large number of requests from potentially many users, as they are being serviced by a single process.

1 Like