From 8d7a6260741abaabfbb2736d4566bfe2946406d9 Mon Sep 17 00:00:00 2001 From: Johnny Robeson Date: Sat, 1 Oct 2016 05:00:29 -0400 Subject: [PATCH] Move timeout config getter to library from dbcore I wanted to move it up even higher, but I wanted to hold off on that for a bit longer. --- beets/dbcore/db.py | 6 +++--- beets/library.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/beets/dbcore/db.py b/beets/dbcore/db.py index 73233b52c..daa636d24 100644 --- a/beets/dbcore/db.py +++ b/beets/dbcore/db.py @@ -692,8 +692,9 @@ class Database(object): """The Model subclasses representing tables in this database. """ - def __init__(self, path): + def __init__(self, path, timeout=5.0): self.path = path + self.timeout = timeout self._connections = {} self._tx_stacks = defaultdict(list) @@ -732,8 +733,7 @@ class Database(object): # bytestring paths here on Python 3, so we need to # provide a `str` using `py3_path`. conn = sqlite3.connect( - py3_path(self.path), - timeout=beets.config['timeout'].as_number(), + py3_path(self.path), timeout=self.timeout ) # Access SELECT results like dictionaries. diff --git a/beets/library.py b/beets/library.py index d4b9b8189..59784e808 100644 --- a/beets/library.py +++ b/beets/library.py @@ -1216,7 +1216,8 @@ class Library(dbcore.Database): path_formats=((PF_KEY_DEFAULT, '$artist/$album/$track $title'),), replacements=None): - super(Library, self).__init__(path) + timeout = beets.config['timeout'].as_number() + super(Library, self).__init__(path, timeout=timeout) self._connection().create_function('bytelower', 1, _sqlite_bytelower)