# Path: pyzor/engines/common.py
# class DatabaseError(Exception):
# class Record(object):
# class BaseEngine(object):
#     def __init__(self, r_count=0, wl_count=0, r_entered=None,
#                  r_updated=None, wl_entered=None, wl_updated=None):
#     def wl_increment(self):
#     def r_increment(self):
#     def r_update(self):
#     def wl_update(self):
#     def __iter__(self):
#     def iteritems(self):
#     def items(self):
#     def __getitem__(self, key):
#     def __setitem__(self, key, value):
#     def __delitem__(self, key):
#     def report(self, keys):
#     def whitelist(self, keys):
#     def get_prefork_connections(cls, fn, mode, max_age=None):


    import gdbm as gdbm
        import dbm.gnu as gdbm
import time
import logging
import datetime
import threading
from pyzor.engines.common import Record, DBHandle, BaseEngine
        assert len(parts) == len(cls.fields)
        for part, field in zip(parts, cls._fields):
            f, decode = field
            setattr(r, f, decode(part))
        return r


class ThreadedGdbmDBHandle(GdbmDBHandle):
    """Like GdbmDBHandle, but handles multi-threaded access."""

    def __init__(self, fn, mode, max_age=None, bound=None):
        self.db_lock = threading.Lock()
        GdbmDBHandle.__init__(self, fn, mode, max_age=max_age)

    def apply_method(self, method, varargs=(), kwargs=None):
        if kwargs is None:
            kwargs = {}
        with self.db_lock:
            return GdbmDBHandle.apply_method(self, method, varargs=varargs,
                                             kwargs=kwargs)

# This won't work because the gdbm object needs to be in shared memory of the
# spawned processes.
# class ProcessGdbmDBHandle(ThreadedGdbmDBHandle):
# def __init__(self, fn, mode, max_age=None, bound=None):
# ThreadedGdbmDBHandle.__init__(self, fn, mode, max_age=max_age,
#                                       bound=bound)
#         self.db_lock = multiprocessing.Lock()

if not _has_gdbm:

# Path: pyzor/engines/common.py
# class DatabaseError(Exception):
# class Record(object):
# class BaseEngine(object):
#     def __init__(self, r_count=0, wl_count=0, r_entered=None,
#                  r_updated=None, wl_entered=None, wl_updated=None):
#     def wl_increment(self):
#     def r_increment(self):
#     def r_update(self):
#     def wl_update(self):
#     def __iter__(self):
#     def iteritems(self):
#     def items(self):
#     def __getitem__(self, key):
#     def __setitem__(self, key, value):
#     def __delitem__(self, key):
#     def report(self, keys):
#     def whitelist(self, keys):
#     def get_prefork_connections(cls, fn, mode, max_age=None):


# Path: pyzor/engines/gdbm_.py
    import gdbm as gdbm
        import dbm.gnu as gdbm
import time
import logging
import datetime
import threading
from pyzor.engines.common import Record, DBHandle, BaseEngine

        assert len(parts) == len(cls.fields)
        for part, field in zip(parts, cls._fields):
            f, decode = field
            setattr(r, f, decode(part))
        return r


class ThreadedGdbmDBHandle(GdbmDBHandle):
    """Like GdbmDBHandle, but handles multi-threaded access."""

    def __init__(self, fn, mode, max_age=None, bound=None):
        self.db_lock = threading.Lock()
        GdbmDBHandle.__init__(self, fn, mode, max_age=max_age)

    def apply_method(self, method, varargs=(), kwargs=None):
        if kwargs is None:
            kwargs = {}
        with self.db_lock:
            return GdbmDBHandle.apply_method(self, method, varargs=varargs,
                                             kwargs=kwargs)

# This won't work because the gdbm object needs to be in shared memory of the
# spawned processes.
# class ProcessGdbmDBHandle(ThreadedGdbmDBHandle):
# def __init__(self, fn, mode, max_age=None, bound=None):
# ThreadedGdbmDBHandle.__init__(self, fn, mode, max_age=max_age,
#                                       bound=bound)
#         self.db_lock = multiprocessing.Lock()

if not _has_gdbm:

    handle = DBHandle(single_threaded=None,