[FIX] close the cursor when an exception occur
authorChristophe Simonis <christophe@cobalt>
Fri, 19 Dec 2008 19:16:57 +0000 (20:16 +0100)
committerChristophe Simonis <christophe@cobalt>
Fri, 19 Dec 2008 19:16:57 +0000 (20:16 +0100)
bzr revid: christophe@cobalt-20081219191657-03rnpi2t51j3iy5x

bin/service/web_services.py

index 580f9ca..a831cd3 100644 (file)
@@ -462,11 +462,10 @@ class report_spool(netsvc.Service):
         self._reports[id] = {'uid': uid, 'result': False, 'state': False, 'exception': None}
 
         def go(id, uid, ids, datas, context):
+            cr = pooler.get_db(db).cursor()
             try:
-                cr = pooler.get_db(db).cursor()
                 obj = netsvc.LocalService('report.'+object)
                 (result, format) = obj.create(cr, uid, ids, datas, context)
-                cr.close()
                 self._reports[id]['result'] = result
                 self._reports[id]['format'] = format
                 self._reports[id]['state'] = True
@@ -480,6 +479,7 @@ class report_spool(netsvc.Service):
                         'Exception: %s\n%s' % (str(exception), tb_s))
                 self._reports[id]['exception'] = exception
                 self._reports[id]['state'] = True
+            cr.close()
             return True
 
         thread.start_new_thread(go, (id, uid, ids, datas, context))