Fix broken CI and PyMySQL support
This is a combination of two patches that depend on each other to fix a breakage with PyMySQL 0.10.0 and fixing the up the CI to a working state. 1. Blacklist etcd3gw 0.2.6 etcd3gw 0.2.6 was blacklisted in openstack/requirements [0], because that version has a bug [1]. tooz does not use openstack/requirements' upper constraints, so the same blacklisting needs to be introduced here in setup.cfg. [0] Icb6873d8c5d3a3624c0ac3d76fc9125c5d8134b2 [1] https://github.com/dims/etcd3-gateway/issues/41 Change-Id: I22b955419014dd34c63e406c488e0636ffe9013b Closes-Bug: #1891314 (cherry picked from commit3f0759091c
) (cherry picked from commitc8d77ee485
) 2. Fix breakage with PyMySQL 0.10.0 In this version a Connection is no longer a context manager. Fix it by simply getting a Cursor out of it (locks don't seem to interact with transactions, at least according to MariaDB docs). Change-Id: I5ea06ebd2b976465ff82f10a74e140f30e9e803f (cherry picked from commitd59b283440
)
This commit is contained in:
parent
b47e687727
commit
667e2ec1f4
4
releasenotes/notes/mysql-0.10.0-7660f75a1c57a920.yaml
Normal file
4
releasenotes/notes/mysql-0.10.0-7660f75a1c57a920.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixes AttributeError in the ``mysql`` driver with PyMySQL 0.10.0.
|
@ -51,7 +51,7 @@ etcd3 =
|
|||||||
etcd3>=0.12.0 # Apache-2.0
|
etcd3>=0.12.0 # Apache-2.0
|
||||||
grpcio>=1.18.0
|
grpcio>=1.18.0
|
||||||
etcd3gw =
|
etcd3gw =
|
||||||
etcd3gw>=0.1.0 # Apache-2.0
|
etcd3gw!=0.2.6,>=0.1.0 # Apache-2.0
|
||||||
zake =
|
zake =
|
||||||
zake>=0.1.6 # Apache-2.0
|
zake>=0.1.6 # Apache-2.0
|
||||||
redis =
|
redis =
|
||||||
|
@ -61,12 +61,12 @@ class MySQLLock(locking.Lock):
|
|||||||
try:
|
try:
|
||||||
if not self._conn.open:
|
if not self._conn.open:
|
||||||
self._conn.connect()
|
self._conn.connect()
|
||||||
with self._conn as cur:
|
cur = self._conn.cursor()
|
||||||
cur.execute("SELECT GET_LOCK(%s, 0);", self.name)
|
cur.execute("SELECT GET_LOCK(%s, 0);", self.name)
|
||||||
# Can return NULL on error
|
# Can return NULL on error
|
||||||
if cur.fetchone()[0] is 1:
|
if cur.fetchone()[0] == 1:
|
||||||
self.acquired = True
|
self.acquired = True
|
||||||
return True
|
return True
|
||||||
except pymysql.MySQLError as e:
|
except pymysql.MySQLError as e:
|
||||||
utils.raise_with_cause(
|
utils.raise_with_cause(
|
||||||
tooz.ToozError,
|
tooz.ToozError,
|
||||||
@ -90,9 +90,9 @@ class MySQLLock(locking.Lock):
|
|||||||
if not self.acquired:
|
if not self.acquired:
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
with self._conn as cur:
|
cur = self._conn.cursor()
|
||||||
cur.execute("SELECT RELEASE_LOCK(%s);", self.name)
|
cur.execute("SELECT RELEASE_LOCK(%s);", self.name)
|
||||||
cur.fetchone()
|
cur.fetchone()
|
||||||
self.acquired = False
|
self.acquired = False
|
||||||
self._conn.close()
|
self._conn.close()
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user