On Sun, Jun 1, 2014 at 3:01 PM, Wolfgang Mauerer <wm@xxxxxxxxxxxxxxxx> wrote: > Hi Mitchell, > > Am 31/05/2014 12:39, schrieb Mitchell Joblin: > > - Currently the mysql connection is made immediately and then >> the scrapping of the VCS starts >> >> - If the scraping takes a long time then a timeout can >> occur for exampe in very large projects like mozilla >> >> - When the timeout occurs then the analysis fails once the >> scraping is done and attempts are made to write data to the db >> >> - We now ping the server before we make any query and make a >> reconnection attempt if a time out has occured >> > > looks good -- but just to make sure: Does the ping that now comes > with every SQL query cause any performance impact, or is it negigible? > I would suppose there's nothing to worry about, but one never knows. > That is a valid point and I did give it some thought. There is a performance hit and according this ( http://stackoverflow.com/questions/3103969/should-i-ping-mysql-server-before-each-query/3104681#3104681) pinging before each query is not the best approach. I will take another look at this and come up with something better. Kind regards, Mitchell > > Thanks, Wolfgang > > >> > Signed-off-by: Mitchell Joblin <mitchell.joblin.ext@xxxxxxxxxxx> >> --- >> codeface/dbmanager.py | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/codeface/dbmanager.py b/codeface/dbmanager.py >> index 500939e..e74168e 100644 >> --- a/codeface/dbmanager.py >> +++ b/codeface/dbmanager.py >> @@ -60,6 +60,10 @@ class DBManager: >> self.con.close() >> >> def doExec(self, stmt, args=None): >> + # Make sure connection is still available >> + # and attemps reconnect if necessary >> + self.con.ping(True) >> + >> with _log_db_error(stmt, args): >> while True: >> try: >> >> >