7267 |
# as they come in from the server. |
# as they come in from the server. |
7268 |
# |
# |
7269 |
my $cb = sub { |
my $cb = sub { |
7270 |
eval { |
eval |
7271 |
|
{ |
7272 |
|
# |
7273 |
|
# If invoked with (<unused>,'reset'), reset the |
7274 |
|
# last-message-part state. |
7275 |
|
# |
7276 |
|
if (@_ == 2 && $_[1] eq 'reset') |
7277 |
|
{ |
7278 |
|
$tail = ''; |
7279 |
|
return; |
7280 |
|
} |
7281 |
my $c = $tail . shift; |
my $c = $tail . shift; |
7282 |
local $/ = "\n"; |
local $/ = "\n"; |
7283 |
|
|
7329 |
}; $@ and print STDERR "Failed with $@"; |
}; $@ and print STDERR "Failed with $@"; |
7330 |
}; |
}; |
7331 |
|
|
7332 |
|
my $n_retries = 10; |
7333 |
|
my $attempts = 0; |
7334 |
|
|
7335 |
|
$ua->timeout(180); |
7336 |
|
|
7337 |
|
while ($attempts++ < $n_retries) |
7338 |
|
{ |
7339 |
|
$tail = ''; |
7340 |
|
&$cb(undef, 'reset'); |
7341 |
my $resp = $ua->get($req, ':content_cb' => $cb); |
my $resp = $ua->get($req, ':content_cb' => $cb); |
7342 |
# print "tail=$tail\n"; |
# print "tail=$tail\n"; |
7343 |
# print "sims=@sims\n"; |
# print "sims=@sims\n"; |
7348 |
} |
} |
7349 |
else |
else |
7350 |
{ |
{ |
7351 |
print STDERR "Error getting sims: \n"; |
print STDERR "Error getting sims (attempt $attempts of $n_retries): \n"; |
7352 |
print STDERR $resp->content; |
print STDERR $resp->content; |
7353 |
} |
} |
7354 |
} |
} |
7355 |
|
print STDERR "Could not get network sims after $attempts retries; request url is $req\n"; |
7356 |
|
return undef; |
7357 |
|
} |
7358 |
|
|
7359 |
sub sort_sims |
sub sort_sims |
7360 |
{ |
{ |