How to use the queuelib.queue.FifoSQLiteQueue function in queuelib

To help you get started, we’ve selected a few queuelib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scrapy / queuelib / queuelib / queue.py View on Github external
for id_, item in conn.execute(self._sql_pop):
                conn.execute(self._sql_del, (id_,))
                return item

    def close(self):
        size = len(self)
        self._db.close()
        if not size:
            os.remove(self._path)

    def __len__(self):
        with self._db as conn:
            return next(conn.execute(self._sql_size))[0]


class LifoSQLiteQueue(FifoSQLiteQueue):

    _sql_pop = 'SELECT id, item FROM queue ORDER BY id DESC LIMIT 1'