def __init__(self, db_path, drive): """ :param str db_path: A unique path for the database to store items for the target drive. :param onedrive_d.api.drives.DriveObject drive: The underlying drive object. """ if not hasattr(drive, 'storage_lock'): drive.storage_lock = rwlock.RWLock() self.lock = drive.storage_lock self._conn = sqlite3.connect(db_path, isolation_level=None, check_same_thread=False) self.drive = drive self._cursor = self._conn.cursor() self._cursor.execute(get_content('onedrive_items.sql')) self._conn.commit() atexit.register(self.close)
def get_sample_task_pool(): p = task_pool.TaskPool() p._lock = rwlock.RWLock() p._semaphore = threading.Semaphore(0) return p
def get_instance(cls): if cls._instance is None: cls._semaphore = threading.Semaphore(0) cls._lock = rwlock.RWLock() cls._instance = TaskPool() return cls._instance