bug fix: sql lock for parallel processing

This commit is contained in:
Steve Nyemba 2022-06-10 10:11:37 -05:00
parent 40bcfc40f9
commit b2a224f4a7
2 changed files with 6 additions and 4 deletions

View File

@ -8,7 +8,7 @@ def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
args = {
"name":"data-transport",
"version":"1.5.2",
"version":"1.5.3",
"author":"The Phi Technology LLC","author_email":"info@the-phi.com",
"license":"MIT",
"packages":["transport"]}

View File

@ -59,7 +59,7 @@ class SQLRW :
# _info['host'] = 'localhost' if 'host' not in _args else _args['host']
# # _info['port'] = SQLWriter.PROVIDERS[_args['provider']] if 'port' not in _args else _args['port']
# _info['port'] = SQLWriter.REFERENCE[_provider]['port'] if 'port' not in _args else _args['port']
self.lock = False if 'lock' not in _args else _args['lock']
if 'username' in _args or 'user' in _args:
key = 'username' if 'username' in _args else 'user'
_info['user'] = _args[key]
@ -272,7 +272,8 @@ class SQLWriter(SQLRW,Writer):
if _info.shape[0] == 0 :
return
SQLRW.lock.acquire()
if self.lock :
SQLRW.lock.acquire()
if self._engine is not None:
# pd.to_sql(_info,self._engine)
@ -299,7 +300,8 @@ class SQLWriter(SQLRW,Writer):
if self._engine is None :
self.conn.commit()
SQLRW.lock.release()
if self.lock :
SQLRW.lock.release()
# cursor.close()
pass
def close(self):