Skip to content

Commit

Permalink
Don't cache connection when loading JSON
Browse files Browse the repository at this point in the history
Refs #1779
  • Loading branch information
kimrutherford committed Feb 21, 2019
1 parent 5a77fe8 commit b974de5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 8 additions & 3 deletions lib/Canto/Track.pm
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ use Canto::Curs::State qw/:all/;
$pub - the uniquename (PMID) of a publication; the Pub object will be
created if it doesn't exist
OR: a Pub object to use
$connect_options - options passed to cached_connect()
Return :
=cut
Expand All @@ -72,6 +73,7 @@ sub create_curs
my $config = shift;
my $track_schema = shift;
my $pub = shift;
my $connect_options = shift;

if (!ref $pub) {
$pub = $track_schema->resultset('Pub')->find_or_create({ uniquename => $pub });
Expand All @@ -85,20 +87,21 @@ sub create_curs
curs_key => $curs_key,
});

my $curs_db = Canto::Track::create_curs_db($config, $curs);
my $curs_db = Canto::Track::create_curs_db($config, $curs, undef, $connect_options);

return ($curs, $curs_db);
}

=head2 create_curs_db
Usage : Canto::Track::create_curs_db($config, $curs_object);
Usage : Canto::Track::create_curs_db($config, $curs_object, );
Function: Create a database for a curs, using the curs_key field of the object
to create the database (file)name.
Args : $config - the Config object
$curs - the Curs object
$current_user - the current logged in user (or undef if no one is
logged in)
$connect_options - options passed to cached_connect()
Returns : ($curs_schema, $cursdb_file_name) - A CursDB object for the new db,
and its file name - die()s on failure
Expand All @@ -108,6 +111,7 @@ sub create_curs_db
my $config = shift;
my $curs = shift;
my $current_user = shift;
my $connect_options = shift;

if (!defined $curs) {
croak "No Curs object passed";
Expand All @@ -127,7 +131,8 @@ sub create_curs_db
copy($curs_db_template_file, $db_file_name) or die "$!\n";

my $connect_string = Canto::Curs::make_connect_string($config, $curs_key);
my $curs_schema = Canto::CursDB->cached_connect($connect_string);
my $curs_schema = Canto::CursDB->cached_connect($connect_string, undef, undef,
$connect_options);

my $track_db_pub = $curs->pub();
my $curs_db_pub =
Expand Down
5 changes: 4 additions & 1 deletion lib/Canto/Track/LoadUtil.pm
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,9 @@ sub create_sessions_from_json
die qq|can't find user with email address "$curator_email_address" in the database\n|;
}

# disable connection caching so we don't run out of file descriptors
my $connect_options = { cache_connection => 0 };

my @results = ();

while (my ($pub_uniquename, $session_data) = each %$sessions_data) {
Expand All @@ -851,7 +854,7 @@ sub create_sessions_from_json
}

my ($curs, $cursdb) =
Canto::Track::create_curs($config, $self->schema(), $pub);
Canto::Track::create_curs($config, $self->schema(), $pub, $connect_options);

my $gene_manager = Canto::Curs::GeneManager->new(config => $config,
curs_schema => $cursdb);
Expand Down

0 comments on commit b974de5

Please sign in to comment.