I have a function that I want to analyse with cProfile, but I also save a lot of other analysis about the result - this currently gets saved into a directory whose name is generated programatically, and I would like the profile data to be saved in the same directory.
However: the directory name is only worked out after the function I want to profile has finished, in a concurrent.futures
callback function.
Is there an easy way I can keep the profile data in a Python object that can be handed to the callback function (eg, returned along with the function's result) to be written to disk once the filename is known?