[codeface] [PATCH 7/8] Ping mysql server and reconnect if timeout occured

  • From: Mitchell Joblin <joblin.m@xxxxxxxxx>
  • To: codeface@xxxxxxxxxxxxx
  • Date: Sat, 31 May 2014 12:39:34 +0200

- 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

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:
-- 
1.8.3.2


Other related posts: