Skip to content

Commit

Permalink
Merge 7b4f26f into f4df3d1
Browse files Browse the repository at this point in the history
  • Loading branch information
james-monkeyshines committed Nov 11, 2020
2 parents f4df3d1 + 7b4f26f commit b75ffc9
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions lib/Bio/EnsEMBL/DataCheck/Manager.pm
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,21 @@ sub load_config {
if (defined $self->config_file) {
die "Config file does not exist" unless -e $self->config_file;

my $json = path($self->config_file)->slurp;
# 'slurp' gets an exclusive lock on the file before reading it.
# But sometimes we get flock problems, if a bunch of datachecks
# are all completing very quickly, so have a brief pause to
# calm things down a bit. That doesn't always work, so give
# it a second go if the first attempt fails.
my $json;
eval {
sleep(int(rand(10)));
$json = path($self->config_file)->slurp;
};
if ($@) {
sleep(int(rand(10)));
$json = path($self->config_file)->slurp;
}

my %config;
eval {
%config = %{ JSON->new->decode($json) };
Expand Down Expand Up @@ -374,12 +388,12 @@ sub read_history {
# calm things down a bit. That doesn't always work, so give
# it a second go if the first attempt fails.
eval {
sleep(2);
sleep(int(rand(10)));
my $json = path($self->history_file)->slurp;
%history = %{ JSON->new->decode($json) };
};
if ($@) {
sleep(2);
sleep(int(rand(10)));
my $json = path($self->history_file)->slurp;
%history = %{ JSON->new->decode($json) };
}
Expand Down

0 comments on commit b75ffc9

Please sign in to comment.