I am running a flask server and would like to initialize one complicated object for each thread at startup. The initialization is slow but only needs to be done once. After the initialization, speed is not an issue. The operations on the objects are no thread safe, but their contents do not change between requests.
How do I do something like this with flask? How can I perform an initialization task on a per thread basis (rather than a per request basis)?