{pg,my}sql: fix AttributeError on connection failure

If connection fails to be established, the acquired attribute does not
exist and then you see warning such has:

Exception AttributeError: "'MySQLLock' object has no attribute 'acquired'" in
<bound method MySQLLock.__del__ of <tooz.drivers.mysql.MySQLLock object at 0x7f79479056d0>>

Change-Id: Id61775483c91ba4127d9dd8cb56d6629a51d7081
This commit is contained in:
Julien Danjou 2015-11-26 14:32:49 +01:00
parent d272845997
commit df3363e2ea
2 changed files with 2 additions and 2 deletions

View File

@ -33,8 +33,8 @@ class MySQLLock(locking.Lock):
def __init__(self, name, parsed_url, options):
super(MySQLLock, self).__init__(name)
self._conn = MySQLDriver.get_connection(parsed_url, options)
self.acquired = False
self._conn = MySQLDriver.get_connection(parsed_url, options)
def acquire(self, blocking=True):

View File

@ -93,8 +93,8 @@ class PostgresLock(locking.Lock):
def __init__(self, name, parsed_url, options):
super(PostgresLock, self).__init__(name)
self._conn = PostgresDriver.get_connection(parsed_url, options)
self.acquired = False
self._conn = PostgresDriver.get_connection(parsed_url, options)
h = hashlib.md5()
h.update(name)
if six.PY2: