Hello, I use Entity["Isotope",...] to calculate radioactive decay chains. These calculations last up to several days. During this time, I get sometimes network errors because of timeouts:
… EntityValue::conopen: Using EntityValue requires internet connectivity. Please check your network connection. You may need to configure your firewall program or set a proxy in the Internet Connectivity tab of the Preferences dialog.
… EntityValue::nodat: Unable to download data. Some or all results may be missing. The output result is:
Missing[RetrievalFailure]
My internet service provider (isp) does something, I cannot avoid. As a result I must restart the calculation. To avoid this I want to have some code, that ensures, that the Entity[…] request worked correct with no error. I think, that the following code shows what I am searching: Without error handling I defined the function ssEntity (ss as first letter means stored):
ClearAll@ssEntity;
ssEntity[type$of$entity_String,isotope$name_String][propety_String]:=ssEntity[type$of$entity,isotope$name][propety]=Entity[type$of$entity,isotope$name][propety];
ssEntity["Isotope","Pu236"]["AtomicMass"]
gives the correct output
Quantity[236.046057964,"AtomicMassUnit"]
To manage network errors, I defined
ClearAll[sEntity];counted$polls=0;
sEntity[type$of$entity_String,isotope$name_String][propety_String]:=(*sEntity[type$of$entity,isotope$name][propety]=*)Block[{p,f},While[MissingQ@(f=Enclose[ConfirmQuiet[p=Entity[type$of$entity,isotope$name][propety]],Missing[]&]);(**);Pause[1];MissingQ@f,counted$polls++;Echo[{f,p,MissingQ@f,counted$polls}];f];p];
sEntity["Isotope","Pu244"]["AtomicMass"]
doesn’t do what I want with network connection ore without it.
Kind regards from Peter.
Attachments: