You could wrap the call to the *Data function in TimeConstrained
. This function will evaluate its argument for the maximum number of seconds specified. If the computation has not completed in that time, it will return $Aborted
. Of course, you will probably have to manage the aborted computation somehow, but from my reading of your question that doesn't seem to be a problem.
For instance:
TimeConstrained[WeatherData["Chicago", "Temperature", {1950, 1}], 0.1]
returns $Aborted
on my system; if I use a more lax time constrain, e.g. 1 s, I obtain my result.
This problem is particularly relevant for data that need download and initialization of a local archive / index when first accessed, such as the WeatherData
results above. The TimeConstrained
function will stop the loading of the database as well as the data processing in that case.
As an aside, the database loading is incremental in those cases: if you execute the same time-limited expression enough times, it will download and process a small chunk each time, until at the end it will have downloaded everything it needs and will be able to answer from local data, which will be very fast.