mirror of
https://github.com/correl/dejavu.git
synced 2024-11-23 19:19:53 +00:00
Fixed the issue of the default database not being imported.
Fixed a bug in the SQL database pertaining to the use of grouper. Made SQLDatabase pickleable, for better multiprocessing support.
This commit is contained in:
parent
f276efdf32
commit
e071804ea5
2 changed files with 13 additions and 2 deletions
|
@ -164,3 +164,7 @@ def get_database(database_type=None):
|
||||||
return db_cls
|
return db_cls
|
||||||
|
|
||||||
raise TypeError("Unsupported database type supplied.")
|
raise TypeError("Unsupported database type supplied.")
|
||||||
|
|
||||||
|
|
||||||
|
# Import our default database handler
|
||||||
|
import dejavu.database_sql
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from itertools import izip_longest
|
from itertools import izip_longest, ifilter
|
||||||
import Queue
|
import Queue
|
||||||
|
|
||||||
import MySQLdb as mysql
|
import MySQLdb as mysql
|
||||||
|
@ -302,10 +302,17 @@ class SQLDatabase(Database):
|
||||||
# (sid, db_offset - song_sampled_offset)
|
# (sid, db_offset - song_sampled_offset)
|
||||||
yield (sid, offset - mapper[hash])
|
yield (sid, offset - mapper[hash])
|
||||||
|
|
||||||
|
def __getstate__(self):
|
||||||
|
return (self._options,)
|
||||||
|
|
||||||
|
def __setstate__(self, state):
|
||||||
|
self._options, = state
|
||||||
|
self.cursor = cursor_factory(**self._options)
|
||||||
|
|
||||||
|
|
||||||
def grouper(iterable, n, fillvalue=None):
|
def grouper(iterable, n, fillvalue=None):
|
||||||
args = [iter(iterable)] * n
|
args = [iter(iterable)] * n
|
||||||
return izip_longest(fillvalue=fillvalue, *args)
|
return (ifilter(None, values) for values in izip_longest(fillvalue=fillvalue, *args))
|
||||||
|
|
||||||
|
|
||||||
def cursor_factory(**factory_options):
|
def cursor_factory(**factory_options):
|
||||||
|
|
Loading…
Reference in a new issue