* potential fix for #2323 * Update DbCursor.py * replaced RLock with Lock
This commit is contained in:
parent
966f393e20
commit
89e8fd3d3a
1 changed files with 15 additions and 9 deletions
|
@ -1,6 +1,7 @@
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
import gevent
|
import gevent
|
||||||
|
from gevent._threading import Lock
|
||||||
from util import helper
|
from util import helper
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ class DbCursor:
|
||||||
self.db = db
|
self.db = db
|
||||||
self.cursor = conn.cursor()
|
self.cursor = conn.cursor()
|
||||||
self.logging = False
|
self.logging = False
|
||||||
|
self.lock = Lock()
|
||||||
|
|
||||||
def quoteValue(self, value):
|
def quoteValue(self, value):
|
||||||
if type(value) is int:
|
if type(value) is int:
|
||||||
|
@ -98,15 +100,19 @@ class DbCursor:
|
||||||
query, params = self.parseQuery(query, params)
|
query, params = self.parseQuery(query, params)
|
||||||
|
|
||||||
s = time.time()
|
s = time.time()
|
||||||
|
|
||||||
if params: # Query has parameters
|
try:
|
||||||
res = self.cursor.execute(query, params)
|
self.lock.acquire(True)
|
||||||
if self.logging:
|
if params: # Query has parameters
|
||||||
self.db.log.debug(query + " " + str(params) + " (Done in %.4f)" % (time.time() - s))
|
res = self.cursor.execute(query, params)
|
||||||
else:
|
if self.logging:
|
||||||
res = self.cursor.execute(query)
|
self.db.log.debug(query + " " + str(params) + " (Done in %.4f)" % (time.time() - s))
|
||||||
if self.logging:
|
else:
|
||||||
self.db.log.debug(query + " (Done in %.4f)" % (time.time() - s))
|
res = self.cursor.execute(query)
|
||||||
|
if self.logging:
|
||||||
|
self.db.log.debug(query + " (Done in %.4f)" % (time.time() - s))
|
||||||
|
finally:
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
# Log query stats
|
# Log query stats
|
||||||
if self.db.collect_stats:
|
if self.db.collect_stats:
|
||||||
|
|
Loading…
Reference in a new issue