1
0
mirror of https://github.com/balkian/tsih.git synced 2024-12-22 05:58:13 +00:00

Remove unnecessary exception flush_cache on readonly dbs

This commit is contained in:
J. Fernando Sánchez 2022-03-08 09:51:45 +01:00
parent c857890d91
commit 92c5c219bd

View File

@ -10,7 +10,7 @@ import tempfile
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
__version__ = '0.1.5' __version__ = '0.1.6'
from collections import UserDict, namedtuple from collections import UserDict, namedtuple
@ -240,7 +240,7 @@ class History:
The cache will be flushed at the end of the simulation, and when history is accessed. The cache will be flushed at the end of the simulation, and when history is accessed.
''' '''
if self.readonly: if self.readonly:
raise Exception('DB in readonly mode') return
logger.debug('Flushing cache {}'.format(self.db_path)) logger.debug('Flushing cache {}'.format(self.db_path))
with self.db: with self.db:
self.db.executemany("replace into history(dict_id, t_step, key, value) values (?, ?, ?, ?)", self._tups) self.db.executemany("replace into history(dict_id, t_step, key, value) values (?, ?, ?, ?)", self._tups)