[Chicago-talk] LWP can't wait for data

JJacobus at PonyX.com JJacobus at PonyX.com
Tue Feb 28 10:33:29 PST 2012


I have several backend jobs that grab data from our customers using 
LWP::UserAgent (they provide information in an XML format that's used 
to update our database overnight). I have a problem with one 
customer's data because of a delay pulling data from their database. 
It takes about 66 seconds for their database to respond and send results.
When I make the "get" call, LWP immediately comes back as unsucessful.
I've tried various timeouts with no luck.
I've tried numerous crazy loops and sleeps without success too.

I've confirmed that the "get()" is seen by the remote server and the 
data is eventually presented, but LWP receives a null response 
(failure) immediately.
I don't think it is a timeout problem, since lwp is seeing an 
immediate reponse. It's just that there is no data in the response 
until about 60 seconds later.

Code snippet:
	$file_url = 'http://data.example.com/Feed.ashx?username=user&password=pass';
	my $ua = LWP::UserAgent->new;
	$ua->timeout(300);
	my $response = $ua->get($file_url);
	if ($response->is_success)
	{ 	print "Response was successful\n";
		... (good)
	} else { print "Response was not successful\n"; }
		...(bad) ...
			
Any ideas? Should I look at something other the LWP?

Regards,
Jim



More information about the Chicago-talk mailing list