Skip to content
Snippets Groups Projects
Commit a268e25c authored by ale's avatar ale
Browse files

waste memory

parent 77fdebec
No related branches found
No related tags found
No related merge requests found
......@@ -99,7 +99,9 @@ class StateDatabase(object):
"""Simple key-value database that encodes data with a codec."""
def __init__(self, path, codec=json):
self.db = leveldb.LevelDB(path)
self.db = leveldb.LevelDB(
path,
block_cache_size=256 * (1 << 20))
self.codec = codec
def session(self):
......@@ -157,17 +159,7 @@ def transaction(db):
finally:
session.close()
@contextlib.contextmanager
def readonly_transaction(db):
for i in xrange(3):
try:
with transaction(db) as session:
yield session
except leveldb.LevelDBError:
time.sleep(0.01)
continue
break
readonly_transaction = transaction
@contextlib.contextmanager
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment