Try to avoid some locking issues.
This commit is contained in:
parent
57c37ac453
commit
e10dc36219
@ -46,9 +46,15 @@ class Database(object):
|
|||||||
def _release(self):
|
def _release(self):
|
||||||
if not hasattr(self.local, 'tx'):
|
if not hasattr(self.local, 'tx'):
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
|
self.local.must_release = False
|
||||||
else:
|
else:
|
||||||
self.local.must_release = True
|
self.local.must_release = True
|
||||||
|
|
||||||
|
def _release_internal(self):
|
||||||
|
if not hasattr(self.local, 'must_release') and self.local.must_release:
|
||||||
|
self.lock.release()
|
||||||
|
self.local.must_release = False
|
||||||
|
|
||||||
def begin(self):
|
def begin(self):
|
||||||
""" Enter a transaction explicitly. No data will be written
|
""" Enter a transaction explicitly. No data will be written
|
||||||
until the transaction has been committed. """
|
until the transaction has been committed. """
|
||||||
@ -62,18 +68,14 @@ class Database(object):
|
|||||||
since the transaction was begun permanent. """
|
since the transaction was begun permanent. """
|
||||||
self.local.tx.commit()
|
self.local.tx.commit()
|
||||||
del self.local.tx
|
del self.local.tx
|
||||||
if not hasattr(self.local, 'must_release'):
|
self._release_internal()
|
||||||
self.lock.release()
|
|
||||||
del self.local.must_release
|
|
||||||
|
|
||||||
def rollback(self):
|
def rollback(self):
|
||||||
""" Roll back the current transaction, discarding all statements
|
""" Roll back the current transaction, discarding all statements
|
||||||
executed since the transaction was begun. """
|
executed since the transaction was begun. """
|
||||||
self.local.tx.rollback()
|
self.local.tx.rollback()
|
||||||
del self.local.tx
|
del self.local.tx
|
||||||
if not hasattr(self.local, 'must_release'):
|
self._release_internal()
|
||||||
self.lock.release()
|
|
||||||
del self.local.must_release
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tables(self):
|
def tables(self):
|
||||||
|
|||||||
@ -213,7 +213,7 @@ class Table(object):
|
|||||||
if name not in self.table.columns.keys():
|
if name not in self.table.columns.keys():
|
||||||
col = Column(name, type)
|
col = Column(name, type)
|
||||||
col.create(self.table,
|
col.create(self.table,
|
||||||
connection=self.database.engine)
|
connection=self.database.executable)
|
||||||
finally:
|
finally:
|
||||||
self.database._release()
|
self.database._release()
|
||||||
|
|
||||||
|
|||||||
2
setup.py
2
setup.py
@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='dataset',
|
name='dataset',
|
||||||
version='0.3.5',
|
version='0.3.6',
|
||||||
description="Toolkit for Python-based data processing.",
|
description="Toolkit for Python-based data processing.",
|
||||||
long_description="",
|
long_description="",
|
||||||
classifiers=[
|
classifiers=[
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user