Commit 4457a436 authored by Keith Jolley's avatar Keith Jolley
Browse files

Dataconnector method to drop all connections - needed for REST.

parent 956d4097
...@@ -33,10 +33,7 @@ sub new { ...@@ -33,10 +33,7 @@ sub new {
sub DESTROY { sub DESTROY {
my ($self) = @_; my ($self) = @_;
foreach my $db ( keys %{ $self->{'db'} } ) { $self->drop_all_connections;
$self->_finish_active_statement_handles( $self->{'db'}->{$db}, 1 );
eval { $self->{'db'}->{$db}->disconnect and $logger->info("Disconnected from database $self->{'db'}->{$db}->{'Name'}") };
}
return; return;
} }
...@@ -72,6 +69,16 @@ sub drop_connection { ...@@ -72,6 +69,16 @@ sub drop_connection {
return; return;
} }
sub drop_all_connections {
my ($self) = @_;
foreach my $db ( keys %{ $self->{'db'} } ) {
$self->_finish_active_statement_handles( $self->{'db'}->{$db}, 1 );
eval { $self->{'db'}->{$db}->disconnect and $logger->info("Disconnected from database $self->{'db'}->{$db}->{'Name'}") };
delete $self->{'db'}->{$db};
}
return;
}
sub get_connection { sub get_connection {
my ( $self, $attributes ) = @_; my ( $self, $attributes ) = @_;
my $host = $attributes->{'host'} || $self->{'system'}->{'host'}; my $host = $attributes->{'host'} || $self->{'system'}->{'host'};
......
#Written by Keith Jolley #Written by Keith Jolley
#Copyright (c) 2010-2014, University of Oxford #Copyright (c) 2010-2015, University of Oxford
#E-mail: keith.jolley@zoo.ox.ac.uk #E-mail: keith.jolley@zoo.ox.ac.uk
# #
#This file is part of Bacterial Isolate Genome Sequence Database (BIGSdb). #This file is part of Bacterial Isolate Genome Sequence Database (BIGSdb).
...@@ -130,6 +130,7 @@ sub get_field_values_by_designations { ...@@ -130,6 +130,7 @@ sub get_field_values_by_designations {
while ( my $data = $self->{'sql'}->{"field_values_$query_key"}->fetchrow_hashref ) { while ( my $data = $self->{'sql'}->{"field_values_$query_key"}->fetchrow_hashref ) {
push @$field_data, $data; push @$field_data, $data;
} }
$self->{'db'}->commit; #Prevent IDLE in transaction locks in long-running REST process.
return $field_data; return $field_data;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment