Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

WeatherNWS Timeout

by arashi (Priest)
on Aug 28, 2002 at 19:28 UTC ( #193551=perlquestion: print w/ replies, xml ) Need Help??
arashi has asked for the wisdom of the Perl Monks concerning the following question:

I'm using the Geo::WeatherNWS module to get METAR data, and it works fine...for the most part. Sometimes when trying to access the server, the script will hang and there doesn't seem to be any timeout check in the module. Is there something I can do that would allow me to set a timeout for the script, so it doesn't hang (I'll probably use the last good values if it fails)?
#!/usr/bin/perl -w use strict; use Geo::WeatherNWS; my $Report=Geo::WeatherNWS::new(); $Report->setservername("weather.noaa.gov"); $Report->setusername("anonymous"); $Report->setpassword('anemailuser@adomain.com'); $Report->setdirectory("/data/observations/metar/stations"); $Report->getreport('kmrj'); print $report;
Thanks in advance for your help
Arashi

Comment on WeatherNWS Timeout
Download Code
Re: WeatherNWS Timeout
by fglock (Vicar) on Aug 28, 2002 at 19:38 UTC

    perldoc perlipc shows how to setup a timeout (It might not work in Windows):

    eval { local $SIG{ALRM} = sub { die "alarm clock restart" }; alarm 10; # your code here alarm 0; }; if ($@ and $@ !~ /alarm clock restart/) { die }

Re: WeatherNWS Timeout
by BrowserUk (Pope) on Aug 28, 2002 at 19:44 UTC

    Geo::WeatherNWS uses NET::ftp, and that has an optional timeout setting which defaults to 120 seconds.

    You might need to dig into the source of Geo::WeatherNWS and adjust or add this setting to some reasonable value for your needs.

    Or you could cantact the authors and ask them to make an adjustment, or offer them a patch if your confident enough to try that.


    What's this about a "crooked mitre"? I'm good at woodwork!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://193551]
Approved by jlk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (17)
As of 2014-07-30 17:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (237 votes), past polls