Mercurial > p > roundup > code
changeset 4415:3e35233ea93c
new rdbms config item sqlite_timeout...
...makes the previously hard-coded timeout of 30 seconds
configurable. This is the time a client waits for the locked database
to become free before giving up. Used only for SQLite backend.
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Tue, 07 Sep 2010 15:42:04 +0000 |
| parents | 399569ff4aed |
| children | 36d52125c9cf |
| files | CHANGES.txt roundup/backends/back_sqlite.py roundup/configuration.py |
| diffstat | 3 files changed, 15 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Tue Sep 07 14:49:52 2010 +0000 +++ b/CHANGES.txt Tue Sep 07 15:42:04 2010 +0000 @@ -13,6 +13,10 @@ title with the changed subject. Thanks to Arkadiusz Kita and Peter Funk for requesting the feature and discussing the implementation. http://thread.gmane.org/gmane.comp.bug-tracking.roundup.user/10169 +- new rdbms config item sqlite_timeout makes the previously hard-coded + timeout of 30 seconds configurable. This is the time a client waits + for the locked database to become free before giving up. Used only for + SQLite backend. Fixed:
--- a/roundup/backends/back_sqlite.py Tue Sep 07 14:49:52 2010 +0000 +++ b/roundup/backends/back_sqlite.py Tue Sep 07 15:42:04 2010 +0000 @@ -75,11 +75,11 @@ def sqlite_busy_handler(self, data, table, count): """invoked whenever SQLite tries to access a database that is locked""" + now = time.time() if count == 1: - # use a 30 second timeout (extraordinarily generous) - # for handling locked database - self._busy_handler_endtime = time.time() + 30 - elif time.time() > self._busy_handler_endtime: + # Timeout for handling locked database (default 30s) + self._busy_handler_endtime = now + self.config.RDBMS_SQLITE_TIMEOUT + elif now > self._busy_handler_endtime: # timeout expired - no more retries return 0 # sleep adaptively as retry count grows, @@ -100,13 +100,13 @@ db = os.path.join(self.config.DATABASE, 'db') logging.getLogger('hyperdb').info('open database %r'%db) - # set a 30 second timeout (extraordinarily generous) for handling - # locked database + # set timeout (30 second default is extraordinarily generous) + # for handling locked database if sqlite_version == 1: conn = sqlite.connect(db=db) conn.db.sqlite_busy_handler(self.sqlite_busy_handler) else: - conn = sqlite.connect(db, timeout=30) + conn = sqlite.connect(db, timeout=self.config.RDBMS_SQLITE_TIMEOUT) conn.row_factory = sqlite.Row # pysqlite2 / sqlite3 want us to store Unicode in the db but
--- a/roundup/configuration.py Tue Sep 07 14:49:52 2010 +0000 +++ b/roundup/configuration.py Tue Sep 07 15:42:04 2010 +0000 @@ -604,6 +604,10 @@ (NullableOption, 'read_default_group', 'roundup', "Name of the group to use in the MySQL defaults file (.my.cnf).\n" "Only used in MySQL connections."), + (IntegerNumberOption, 'sqlite_timeout', '30', + "Number of seconds to wait when the SQLite database is locked\n" + "Default: use a 30 second timeout (extraordinarily generous)\n" + "Only used in SQLite connections."), (IntegerNumberOption, 'cache_size', '100', "Size of the node cache (in elements)"), ), "Settings in this section are used"
