示例#1
0
    def iteritems(self):
        if not self.db:
            return
        self._kill_iteration = False
        self._in_iter += 1
        try:
            try:
                cur = self._make_iter_cursor()
                kv = _DeadlockWrap(cur.first)
                key = kv[0]
                yield kv
                next = getattr(cur, 'next')
                while 1:
                    try:
                        kv = _DeadlockWrap(next)
                        key = kv[0]
                        yield kv
                    except _bsddb.DBCursorClosedError:
                        if self._kill_iteration:
                            raise RuntimeError('Database changed size during iteration.')
                        cur = self._make_iter_cursor()
                        _DeadlockWrap(cur.set, key, 0, 0, 0)
                        next = getattr(cur, 'next')

            except _bsddb.DBNotFoundError:
                pass
            except _bsddb.DBCursorClosedError:
                pass

        except:
            self._in_iter -= 1
            raise

        self._in_iter -= 1
示例#2
0
 def _checkCursor(self):
     if self.dbc is None:
         self.dbc = _DeadlockWrap(self.db.cursor)
         if self.saved_dbc_key is not None:
             _DeadlockWrap(self.dbc.set, self.saved_dbc_key)
             self.saved_dbc_key = None
     return
示例#3
0
    def iteritems(self):
        if not self.db:
            return
        self._kill_iteration = False
        self._in_iter += 1
        try:
            try:
                cur = self._make_iter_cursor()
                kv = _DeadlockWrap(cur.first)
                key = kv[0]
                yield kv
                next = getattr(cur, 'next')
                while 1:
                    try:
                        kv = _DeadlockWrap(next)
                        key = kv[0]
                        yield kv
                    except _bsddb.DBCursorClosedError:
                        if self._kill_iteration:
                            raise RuntimeError(
                                'Database changed size during iteration.')
                        cur = self._make_iter_cursor()
                        _DeadlockWrap(cur.set, key, 0, 0, 0)
                        next = getattr(cur, 'next')

            except _bsddb.DBNotFoundError:
                pass
            except _bsddb.DBCursorClosedError:
                pass

        except:
            self._in_iter -= 1
            raise

        self._in_iter -= 1
示例#4
0
 def _checkCursor(self):
     if self.dbc is None:
         self.dbc = _DeadlockWrap(self.db.cursor)
         if self.saved_dbc_key is not None:
             _DeadlockWrap(self.dbc.set, self.saved_dbc_key)
             self.saved_dbc_key = None
     return
示例#5
0
    def __iter__(self):
        self._kill_iteration = False
        self._in_iter += 1
        try:
            try:
                cur = self._make_iter_cursor()
                key = _DeadlockWrap(cur.first, 0, 0, 0)[0]
                yield key
                next = getattr(cur, "next")
                while 1:
                    try:
                        key = _DeadlockWrap(next, 0, 0, 0)[0]
                        yield key
                    except _bsddb.DBCursorClosedError:
                        if self._kill_iteration:
                            raise RuntimeError("Database changed size during iteration.")
                        cur = self._make_iter_cursor()
                        _DeadlockWrap(cur.set, key, 0, 0, 0)
                        next = getattr(cur, "next")

            except _bsddb.DBNotFoundError:
                pass
            except _bsddb.DBCursorClosedError:
                pass

        except:
            self._in_iter -= 1
            raise

        self._in_iter -= 1
示例#6
0
 def __setitem__(self, key, value):
     self._checkOpen()
     self._closeCursors()
     if self._in_iter and key not in self:
         self._kill_iteration = True
     def wrapF():
         self.db[key] = value
     _DeadlockWrap(wrapF)  # self.db[key] = value
示例#7
0
    def __delitem__(self, key):
        self._checkOpen()
        self._closeCursors()

        def wrapF():
            del self.db[key]

        _DeadlockWrap(wrapF)  # del self.db[key]
示例#8
0
    def __setitem__(self, key, value):
        self._checkOpen()
        self._closeCursors()

        def wrapF():
            self.db[key] = value

        _DeadlockWrap(wrapF)  # self.db[key] = value
示例#9
0
文件: __init__.py 项目: 0xcc/pyston
 def __setitem__(self, key, value):
     self._checkOpen()
     self._closeCursors()
     if self._in_iter and key not in self:
         self._kill_iteration = True
     def wrapF():
         self.db[key] = value
     _DeadlockWrap(wrapF)  # self.db[key] = value
示例#10
0
文件: __init__.py 项目: 0xcc/pyston
 def __delitem__(self, key):
     self._checkOpen()
     self._closeCursors()
     if self._in_iter and key in self:
         self._kill_iteration = True
     def wrapF():
         del self.db[key]
     _DeadlockWrap(wrapF)  # del self.db[key]
示例#11
0
 def __delitem__(self, key):
     self._checkOpen()
     self._closeCursors()
     if self._in_iter and key in self:
         self._kill_iteration = True
     def wrapF():
         del self.db[key]
     _DeadlockWrap(wrapF)  # del self.db[key]
示例#12
0
文件: __init__.py 项目: 0xcc/pyston
 def close(self):
     self._closeCursors(save=0)
     if self.dbc is not None:
         _DeadlockWrap(self.dbc.close)
     v = 0
     if self.db is not None:
         v = _DeadlockWrap(self.db.close)
     self.dbc = None
     self.db = None
     return v
示例#13
0
 def close(self):
     self._closeCursors(save=0)
     if self.dbc is not None:
         _DeadlockWrap(self.dbc.close)
     v = 0
     if self.db is not None:
         v = _DeadlockWrap(self.db.close)
     self.dbc = None
     self.db = None
     return v
示例#14
0
 def _closeCursors(self, save=1):
     if self.dbc:
         c = self.dbc
         self.dbc = None
         if save:
             try:
                 self.saved_dbc_key = _DeadlockWrap(c.current, 0, 0, 0)[0]
             except db.DBError:
                 pass
         _DeadlockWrap(c.close)
         del c
     for cref in self._cursor_refs.values():
         c = cref()
         if c is not None:
             _DeadlockWrap(c.close)
示例#15
0
文件: __init__.py 项目: 0xcc/pyston
 def _closeCursors(self, save=1):
     if self.dbc:
         c = self.dbc
         self.dbc = None
         if save:
             try:
                 self.saved_dbc_key = _DeadlockWrap(c.current, 0,0,0)[0]
             except db.DBError:
                 pass
         _DeadlockWrap(c.close)
         del c
     for cref in self._cursor_refs.values():
         c = cref()
         if c is not None:
             _DeadlockWrap(c.close)
示例#16
0
文件: __init__.py 项目: 0xcc/pyston
 def last(self):
     self._checkOpen()
     # fix 1725856: don't needlessly try to restore our cursor position
     self.saved_dbc_key = None
     self._checkCursor()
     rv = _DeadlockWrap(self.dbc.last)
     return rv
示例#17
0
 def last(self):
     self._checkOpen()
     # fix 1725856: don't needlessly try to restore our cursor position
     self.saved_dbc_key = None
     self._checkCursor()
     rv = _DeadlockWrap(self.dbc.last)
     return rv
示例#18
0
    def iteritems(self):
        if not self.db:
            return
        self._kill_iteration = False
        self._in_iter += 1
        try:
            try:
                cur = self._make_iter_cursor()

                # FIXME-20031102-greg: race condition.  cursor could
                # be closed by another thread before this call.

                kv = _DeadlockWrap(cur.first)
                key = kv[0]
                yield kv

                next = getattr(cur, "next")
                while 1:
                    try:
                        kv = _DeadlockWrap(next)
                        key = kv[0]
                        yield kv
                    except _bsddb.DBCursorClosedError:
                        if self._kill_iteration:
                            raise RuntimeError('Database changed size '
                                               'during iteration.')
                        cur = self._make_iter_cursor()
                        # FIXME-20031101-greg: race condition.  cursor could
                        # be closed by another thread before this call.
                        _DeadlockWrap(cur.set, key, 0, 0, 0)
                        next = getattr(cur, "next")
            except _bsddb.DBNotFoundError:
                pass
            except _bsddb.DBCursorClosedError:
                # the database was modified during iteration.  abort.
                pass


# When Python 2.3 not supported in bsddb3, we can change this to "finally"
        except:
            self._in_iter -= 1
            raise

        self._in_iter -= 1
示例#19
0
文件: __init__.py 项目: 0xcc/pyston
    def iteritems(self):
        if not self.db:
            return
        self._kill_iteration = False
        self._in_iter += 1
        try:
            try:
                cur = self._make_iter_cursor()

                # FIXME-20031102-greg: race condition.  cursor could
                # be closed by another thread before this call.

                kv = _DeadlockWrap(cur.first)
                key = kv[0]
                yield kv

                next = getattr(cur, "next")
                while 1:
                    try:
                        kv = _DeadlockWrap(next)
                        key = kv[0]
                        yield kv
                    except _bsddb.DBCursorClosedError:
                        if self._kill_iteration:
                            raise RuntimeError('Database changed size '
                                               'during iteration.')
                        cur = self._make_iter_cursor()
                        # FIXME-20031101-greg: race condition.  cursor could
                        # be closed by another thread before this call.
                        _DeadlockWrap(cur.set, key,0,0,0)
                        next = getattr(cur, "next")
            except _bsddb.DBNotFoundError:
                pass
            except _bsddb.DBCursorClosedError:
                # the database was modified during iteration.  abort.
                pass
# When Python 2.4 not supported in bsddb3, we can change this to "finally"
        except :
            self._in_iter -= 1
            raise

        self._in_iter -= 1
示例#20
0
    def __iter__(self):
        self._kill_iteration = False
        self._in_iter += 1
        try:
            try:
                cur = self._make_iter_cursor()

                # FIXME-20031102-greg: race condition.  cursor could
                # be closed by another thread before this call.

                # since we're only returning keys, we call the cursor
                # methods with flags=0, dlen=0, dofs=0
                key = _DeadlockWrap(cur.first, 0, 0, 0)[0]
                yield key

                next = getattr(cur, "next")
                while 1:
                    try:
                        key = _DeadlockWrap(next, 0, 0, 0)[0]
                        yield key
                    except _bsddb.DBCursorClosedError:
                        if self._kill_iteration:
                            raise RuntimeError('Database changed size '
                                               'during iteration.')
                        cur = self._make_iter_cursor()
                        # FIXME-20031101-greg: race condition.  cursor could
                        # be closed by another thread before this call.
                        _DeadlockWrap(cur.set, key, 0, 0, 0)
                        next = getattr(cur, "next")
            except _bsddb.DBNotFoundError:
                pass
            except _bsddb.DBCursorClosedError:
                # the database was modified during iteration.  abort.
                pass
# When Python 2.3 not supported in bsddb3, we can change this to "finally"
        except:
            self._in_iter -= 1
            raise

        self._in_iter -= 1
示例#21
0
文件: __init__.py 项目: 0xcc/pyston
    def __iter__(self):
        self._kill_iteration = False
        self._in_iter += 1
        try:
            try:
                cur = self._make_iter_cursor()

                # FIXME-20031102-greg: race condition.  cursor could
                # be closed by another thread before this call.

                # since we're only returning keys, we call the cursor
                # methods with flags=0, dlen=0, dofs=0
                key = _DeadlockWrap(cur.first, 0,0,0)[0]
                yield key

                next = getattr(cur, "next")
                while 1:
                    try:
                        key = _DeadlockWrap(next, 0,0,0)[0]
                        yield key
                    except _bsddb.DBCursorClosedError:
                        if self._kill_iteration:
                            raise RuntimeError('Database changed size '
                                               'during iteration.')
                        cur = self._make_iter_cursor()
                        # FIXME-20031101-greg: race condition.  cursor could
                        # be closed by another thread before this call.
                        _DeadlockWrap(cur.set, key,0,0,0)
                        next = getattr(cur, "next")
            except _bsddb.DBNotFoundError:
                pass
            except _bsddb.DBCursorClosedError:
                # the database was modified during iteration.  abort.
                pass
# When Python 2.4 not supported in bsddb3, we can change this to "finally"
        except :
            self._in_iter -= 1
            raise

        self._in_iter -= 1
示例#22
0
文件: __init__.py 项目: B-Rich/breve
 def next(self):
     self._checkOpen()
     self._checkCursor()
     rv = _DeadlockWrap(self.dbc.next)
     return rv
示例#23
0
文件: __init__.py 项目: B-Rich/breve
 def __setitem__(self, key, value):
     self._checkOpen()
     self._closeCursors()
     def wrapF():
         self.db[key] = value
     _DeadlockWrap(wrapF)  # self.db[key] = value
示例#24
0
文件: __init__.py 项目: B-Rich/breve
 def __delitem__(self, key):
     self._checkOpen()
     self._closeCursors()
     def wrapF():
         del self.db[key]
     _DeadlockWrap(wrapF)  # del self.db[key]
示例#25
0
文件: __init__.py 项目: 0xcc/pyston
 def __getitem__(self, key):
     self._checkOpen()
     return _DeadlockWrap(lambda: self.db[key])  # self.db[key]
示例#26
0
 def __getitem__(self, key):
     self._checkOpen()
     return _DeadlockWrap(lambda: self.db[key])  # self.db[key]
示例#27
0
 def previous(self):
     self._checkOpen()
     self._checkCursor()
     rv = _DeadlockWrap(self.dbc.prev)
     return rv
示例#28
0
文件: __init__.py 项目: 0xcc/pyston
 def __len__(self):
     self._checkOpen()
     return _DeadlockWrap(lambda: len(self.db))  # len(self.db)
示例#29
0
 def next(self):
     self._checkOpen()
     self._checkCursor()
     rv = _DeadlockWrap(getattr(self.dbc, 'next'))
     return rv
示例#30
0
 def next(self):  # Renamed by "2to3"
     self._checkOpen()
     self._checkCursor()
     rv = _DeadlockWrap(getattr(self.dbc, "next"))
     return rv
示例#31
0
文件: __init__.py 项目: 0xcc/pyston
 def sync(self):
     self._checkOpen()
     return _DeadlockWrap(self.db.sync)
示例#32
0
文件: __init__.py 项目: 0xcc/pyston
 def previous(self):
     self._checkOpen()
     self._checkCursor()
     rv = _DeadlockWrap(self.dbc.prev)
     return rv
示例#33
0
文件: __init__.py 项目: 0xcc/pyston
 def set_location(self, key):
     self._checkOpen()
     self._checkCursor()
     return _DeadlockWrap(self.dbc.set_range, key)
示例#34
0
 def last(self):
     self._checkOpen()
     self.saved_dbc_key = None
     self._checkCursor()
     rv = _DeadlockWrap(self.dbc.last)
     return rv
示例#35
0
 def last(self):
     self._checkOpen()
     self.saved_dbc_key = None
     self._checkCursor()
     rv = _DeadlockWrap(self.dbc.last)
     return rv
示例#36
0
 def next(self):
     self._checkOpen()
     self._checkCursor()
     rv = _DeadlockWrap(self.dbc.next)
     return rv
示例#37
0
文件: __init__.py 项目: 0xcc/pyston
 def keys(self):
     self._checkOpen()
     return _DeadlockWrap(self.db.keys)
示例#38
0
文件: __init__.py 项目: 0xcc/pyston
 def __repr__(self) :
     if self.isOpen() :
         return repr(dict(_DeadlockWrap(self.db.items)))
     return repr(dict())
示例#39
0
 def __len__(self):
     self._checkOpen()
     return _DeadlockWrap(lambda: len(self.db))  # len(self.db)
示例#40
0
 def last(self):
     self._checkOpen()
     self._checkCursor()
     rv = _DeadlockWrap(self.dbc.last)
     return rv
示例#41
0
 def __repr__(self):
     if self.isOpen():
         return repr(dict(_DeadlockWrap(self.db.items)))
     return repr(dict())
示例#42
0
 def next(self):
     self._checkOpen()
     self._checkCursor()
     rv = _DeadlockWrap(getattr(self.dbc, 'next'))
     return rv
示例#43
0
 def sync(self):
     self._checkOpen()
     return _DeadlockWrap(self.db.sync)
示例#44
0
文件: __init__.py 项目: 0xcc/pyston
 def has_key(self, key):
     self._checkOpen()
     return _DeadlockWrap(self.db.has_key, key)
示例#45
0
 def _make_iter_cursor(self):
     cur = _DeadlockWrap(self.db.cursor)
     key = id(cur)
     self._cursor_refs[key] = ref(cur, self._gen_cref_cleaner(key))
     return cur
示例#46
0
文件: __init__.py 项目: 0xcc/pyston
 def next(self):  # Renamed by "2to3"
     self._checkOpen()
     self._checkCursor()
     rv = _DeadlockWrap(getattr(self.dbc, "next"))
     return rv
示例#47
0
 def keys(self):
     self._checkOpen()
     return _DeadlockWrap(self.db.keys)
示例#48
0
 def has_key(self, key):
     self._checkOpen()
     return _DeadlockWrap(self.db.has_key, key)
示例#49
0
 def set_location(self, key):
     self._checkOpen()
     self._checkCursor()
     return _DeadlockWrap(self.dbc.set_range, key)
示例#50
0
文件: __init__.py 项目: 0xcc/pyston
 def _make_iter_cursor(self):
     cur = _DeadlockWrap(self.db.cursor)
     key = id(cur)
     self._cursor_refs[key] = ref(cur, self._gen_cref_cleaner(key))
     return cur
示例#51
0
 def last(self):
     self._checkOpen()
     self._checkCursor()
     rv = _DeadlockWrap(self.dbc.last)
     return rv