Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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(""); $Report->setusername("anonymous"); $Report->setpassword(''); $Report->setdirectory("/data/observations/metar/stations"); $Report->getreport('kmrj'); print $report;
Thanks in advance for your help

Replies are listed 'Best First'.
Re: WeatherNWS Timeout
by BrowserUk (Patriarch) 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!
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 }

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2023-03-31 21:53 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (76 votes). Check out past polls.