From e5d291dcb8ad476ae12a9909d5a1f575a08124d0 Mon Sep 17 00:00:00 2001 From: Ian Longden <ianl@sanger.ac.uk> Date: Fri, 22 Jul 2011 14:22:01 +0000 Subject: [PATCH] fix for errors in getting a database connection when in disconnect_when_inactive set and is being called to0 fast for the system to keep up with --- modules/Bio/EnsEMBL/DBSQL/DBConnection.pm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/Bio/EnsEMBL/DBSQL/DBConnection.pm b/modules/Bio/EnsEMBL/DBSQL/DBConnection.pm index c7547081e7..f24959eeeb 100644 --- a/modules/Bio/EnsEMBL/DBSQL/DBConnection.pm +++ b/modules/Bio/EnsEMBL/DBSQL/DBConnection.pm @@ -225,6 +225,7 @@ sub new { sub connect { my ($self) = @_; + if ( $self->connected() ) { return } $self->connected(1); @@ -304,10 +305,18 @@ sub connect { $self->driver(), $self->dbname(), $self->host(), $self->port() ); + if( $self->{'disconnect_when_inactive'}){ + $self->{'count'}++; + if($self->{'count'} > 1000){ + sleep 1; + print "sleep\n"; + $self->{'count'} = 0; + } + } eval { $dbh = - DBI->connect( $dsn, $self->username(), $self->password(), - { 'RaiseError' => 1 } ); + DBI->connect( $dsn, $self->username(), $self->password(), + { 'RaiseError' => 1 } ); }; } -- GitLab