~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to scripts/branch-rewrite.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-09-05 16:05:38 UTC
  • mfrom: (13813.1.7 disco)
  • Revision ID: launchpad@pqm.canonical.com-20110905160538-kyybbc6zai8958z9
[r=wgrant, allenap,
 jtv][bug=836662] pgbouncer test fixture and db disconnection fix for
 branch-rewrite.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python -uS
2
2
#
3
 
# Copyright 2009 Canonical Ltd.  This software is licensed under the
 
3
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
4
4
# GNU Affero General Public License version 3 (see the file LICENSE).
5
5
 
6
6
# pylint: disable-msg=W0403
19
19
 
20
20
from canonical.database.sqlbase import ISOLATION_LEVEL_AUTOCOMMIT
21
21
from canonical.config import config
 
22
from canonical.launchpad.interfaces.lpstorm import ISlaveStore
 
23
from lp.code.model.branch import Branch
22
24
from lp.codehosting.rewrite import BranchRewriter
23
25
from lp.services.log.loglevels import INFO, WARNING
24
26
from lp.services.scripts.base import LaunchpadScript
60
62
                    return
61
63
            except KeyboardInterrupt:
62
64
                sys.exit()
63
 
            except:
 
65
            except Exception:
64
66
                self.logger.exception('Exception occurred:')
65
67
                print "NULL"
 
68
                # The exception might have been a DisconnectionError or
 
69
                # similar. Cleanup such as database reconnection will
 
70
                # not happen until the transaction is rolled back.
 
71
                # XXX StuartBishop 2011-08-31 bug=819282: We are
 
72
                # explicitly rolling back the store here as a workaround
 
73
                # instead of using transaction.abort()
 
74
                try:
 
75
                    ISlaveStore(Branch).rollback()
 
76
                except Exception:
 
77
                    self.logger.exception('Exception occurred in rollback:')
66
78
 
67
79
 
68
80
if __name__ == '__main__':