8
$\begingroup$

I haven't measured this precisely but it seems the default timeout value for retrieving EntityValues with *Data functions is in the range of tens of seconds. This significantly impacts the execution time if the *Data function is called repeatedly, because I often get an

 EntityValue::timeout: A network operation for EntityValue timed out. Please try again later. >>

error.

Is it possible to manually set the timeout value for such functions that retrieve curated data from Wolfram servers?

$\endgroup$
2
$\begingroup$

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.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks for the suggestion, will test it later. And I can add another While[output === $Aborted, repeat] to deal with timeouts. $\endgroup$ – shrx Jun 9 '15 at 6:18
1
$\begingroup$

You can increase the network timeout for WolframAlpha calls by using:

SetOptions[WolframAlpha, TimeConstraint -> 300]

for example.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Does it work with *Data functions? Can't check right now. $\endgroup$ – shrx Jun 19 '15 at 21:32
  • $\begingroup$ Works for me with the AirportData function. $\endgroup$ – STATWORX Jun 19 '15 at 21:48
  • $\begingroup$ I can't find this in the Preferences GUI anywhere (10.1). Does anyone know if it's there? If not, I can imagine plenty of users wanting access to it in the frontend. $\endgroup$ – hYPotenuser Jul 10 '15 at 21:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.