Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 14e8ca6

Browse files
committed
minor fix
1 parent 9b99530 commit 14e8ca6

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

lib/core/option.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
from lib.core.settings import UNION_CHAR_REGEX
110110
from lib.core.settings import UNKNOWN_DBMS_VERSION
111111
from lib.core.settings import WEBSCARAB_SPLITTER
112+
from lib.core.threads import getCurrentThreadData
112113
from lib.core.update import update
113114
from lib.parse.configfile import configFileParser
114115
from lib.parse.payloads import loadPayloads
@@ -1331,6 +1332,9 @@ class _(unicode): pass
13311332
if conf.code:
13321333
conf.code = int(conf.code)
13331334

1335+
threadData = getCurrentThreadData()
1336+
threadData.reset()
1337+
13341338
def __setConfAttributes():
13351339
"""
13361340
This function set some needed attributes into the configuration

lib/core/threads.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,16 @@ class _ThreadData(threading.local):
3333
"""
3434

3535
def __init__(self):
36-
global shared
36+
self.reset()
37+
38+
def reset(self):
39+
"""
40+
Resets thread data model
41+
"""
3742

3843
self.disableStdOut = False
3944
self.hashDBCursor = None
45+
self.inTransaction = False
4046
self.lastErrorPage = None
4147
self.lastHTTPError = None
4248
self.lastRedirectMsg = None

lib/utils/hashdb.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def __init__(self, filepath):
2222
self.filepath = filepath
2323
self._write_cache = {}
2424
self._cache_lock = threading.Lock()
25-
self._in_transaction = False
2625

2726
def _get_cursor(self):
2827
threadData = getCurrentThreadData()
@@ -109,11 +108,13 @@ def flush(self, forced=False):
109108
self.endTransaction()
110109

111110
def beginTransaction(self):
112-
if not self._in_transaction:
111+
threadData = getCurrentThreadData()
112+
if not threadData.inTransaction:
113113
self.cursor.execute('BEGIN TRANSACTION')
114-
self._in_transaction = True
114+
threadData.inTransaction = True
115115

116116
def endTransaction(self):
117-
if self._in_transaction:
117+
threadData = getCurrentThreadData()
118+
if threadData.inTransaction:
118119
self.cursor.execute('END TRANSACTION')
119-
self._in_transaction = False
120+
threadData.inTransaction = False

0 commit comments

Comments
 (0)