Black Lives Matter. Please consider donating to Black Girls Code today.

Sharing non serializable objects between callbacks

I’ve been reading over the documentation on sharing data:

I have a few objects that I use to extract metadata information for things like axis labels. The objects make some small database calls to gather the metadata. Once created they’re static, I don’t want to re-create them in each callback because they do take a few seconds to initialize. The objects aren’t built to be serialized and it’d be a pain to make them serializable.

This seems like a good use case for global variables. I don’t mind if each subprocess initializes its own set of objects because they aren’t large. But I wanted to ask if there is a better way to store setup variables like this.

Most of the options I see don’t appear to work because the objects aren’t serializable.