~smoser/ubuntu/trusty/maas/lp-1172566

« back to all changes in this revision

Viewing changes to src/maasserver/utils/dblocks.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2014-04-03 13:45:02 UTC
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: package-import@ubuntu.com-20140403134502-8a6wvuqwyuekufh0
Tags: upstream-1.5+bzr2227
ImportĀ upstreamĀ versionĀ 1.5+bzr2227

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
            self.__class__.__name__, self[0], self[1])
71
71
 
72
72
    def is_locked(self):
73
 
        stmt = "SELECT 1 FROM pg_locks WHERE classid = %s AND objid = %s"
 
73
        stmt = (
 
74
            "SELECT 1 FROM pg_locks"
 
75
            " WHERE classid = %s AND objid = %s AND granted"
 
76
        )
74
77
        with closing(connection.cursor()) as cursor:
75
78
            cursor.execute(stmt, self)
76
79
            return len(cursor.fetchall()) >= 1