Wait... what? How the fuck did I miss that? I've got all this fancy caching shit in Panda when all I really need is to get textures.... argh
GetItemIcon() was added like a year ago lol. And the best part is it doesn't require the local cache, it will return the icon path if such an item exists, Slouken knows this but does not think it is a concern for datamining.
Code won't work on initial run on an empty cache, because the tooltip needs to query the server for the item if it is not in your local cache. The code doesn't lock up until the server returns the values. That is to say, your code would have long finished executing with nils before the server has replied your settooltips.
Also note that querying the server for items it hasn't seen since a server restart before may disconnect you. In fact querying for 5 such items within 50 seconds will disconnect you (at the average rate of 1 per 10 seconds). You can be more or less certain your rare mounts will not exist within an hour of a server restart until some guild kills the bosses that drops them (and only if it drops).
That is to say, your computer (in the cache folder) maintains a local cache of items that YOU have seen before since the last patch (or launcher patch), and the server maintains its own cache of items that it has seen before since the last reboot. Your local cache CAN contain items the server hasn't seen before (trying to link these to others will not work, they get sent as plain text), and the server cache can most definitely contain items your local cache hasn't seen before (you get them via settooltip, but this takes "your ping" amount of time).