"timeout" config value (#261)

This commit is contained in:
Adrian Sampson 2011-12-04 18:46:35 -08:00
parent b9d6928278
commit 8736d359c6
4 changed files with 17 additions and 2 deletions

View file

@ -703,6 +703,7 @@ class Library(BaseLibrary):
directory='~/Music',
path_formats=None,
art_filename='cover',
timeout=5.0,
item_fields=ITEM_FIELDS,
album_fields=ALBUM_FIELDS):
if path == ':memory:':
@ -717,7 +718,8 @@ class Library(BaseLibrary):
self.path_formats = path_formats
self.art_filename = bytestring_path(art_filename)
self.conn = sqlite3.connect(self.path)
self.timeout = timeout
self.conn = sqlite3.connect(self.path, timeout)
self.conn.row_factory = sqlite3.Row
# this way we can access our SELECT results like dictionaries

View file

@ -45,6 +45,7 @@ DEFAULT_PATH_FORMATS = {
'singleton': 'Non-Album/$artist/$title',
}
DEFAULT_ART_FILENAME = 'cover'
DEFAULT_TIMEOUT = 5.0
# UI exception. Commands should throw this in order to display
@ -639,12 +640,18 @@ def main(args=None, configfh=None):
path_formats.update(config.items('paths'))
art_filename = \
config_val(config, 'beets', 'art_filename', DEFAULT_ART_FILENAME)
lib_timeout = config_val(config, 'beets', 'timeout', DEFAULT_TIMEOUT)
try:
lib_timeout = float(lib_timeout)
except ValueError:
lib_timeout = DEFAULT_TIMEOUT
db_path = os.path.expanduser(libpath)
try:
lib = library.Library(db_path,
directory,
path_formats,
art_filename)
art_filename,
lib_timeout)
except sqlite3.OperationalError:
raise UserError("database file %s could not be opened" % db_path)

View file

@ -41,6 +41,7 @@ Changelog
via the ``ignore`` setting; see :doc:`/reference/config`.
* The database now keeps track of files' modification times so that, during
an ``update``, unmodified files can be skipped. (Thanks to Jos van der Til.)
* A new ``timeout`` config value avoids database locking errors on slow systems.
* Fix a crash after using the "as Tracks" option during import.
* Fix a Unicode error when tagging items with missing titles.
* Fix a crash when the state file (``~/.beetsstate``) became emptied or

View file

@ -98,6 +98,11 @@ section header:
only in the ``import`` command). Turn this off if your terminal doesn't
support ANSI colors.
``timeout``
The amount of time that the SQLite library should wait before raising an
exception when the database lock is contended. This should almost never need
to be changed except on very slow systems. Defaults to 5.0 (5 seconds).
You can also configure the directory hierarchy beets uses to store music. That
uses the ``[paths]`` section instead of the ``[beets]`` section. Each string is
a `Python template string`_ that can refer to metadata fields (see below for