Populate entire workbook before discarding data

I’m writing an extension (in python) for Calc that adds a function that populates cells with data from the web. The data comes in csv chunks, and the user can utilize specific elements depending on the arguments they give the function. ex:

=MYFUNCTION(ticker, 5)  

would populate the cell with the 5th element of the csv list.

The issue is that if the function is called only once in the sheet then the rest of the elements can be discarded, but if it is called multiple times the other elements may be needed. Is it possible to store elements UNTIL the entire sheet is populated, and then discard them?

Basically, does calc throw a flag that I could catch when it has finished calculating all formulas in a sheet?
Thanks!