Skip to content

Commit

Permalink
Add longer policy fetch timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
ajparsons committed Jan 4, 2024
1 parent 81e888f commit 3f9865f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/json2db.pl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use DBI;
use JSON::XS;
use LWP::Simple;
use LWP::UserAgent;

use vars qw($motion_count $policy_count $align_count);

Expand All @@ -46,13 +47,17 @@

my @policyids = fetch_policies();

my $ua = LWP::UserAgent->new;
$ua->timeout(10); # 10 second timeout

foreach my $dreamid ( @policyids ) {
my $policy_url = mySociety::Config::get('TWFY_VOTES_URL') . '/twfy-compatible/popolo/' . $dreamid . '.json';
my $policy_json = get($policy_url);
if (!$policy_json) {
my $response = $ua->get($policy_url);
unless ($response->is_success) {
warn "no json file for policy $dreamid at $policy_url";
next;
}
my $policy_json = $response->decoded_content;
my $policy = $json->decode($policy_json);

my $curr_policy = $dbh->selectrow_hashref($policycheck, {}, $dreamid);
Expand Down

0 comments on commit 3f9865f

Please sign in to comment.