import threading, time, pickle, random, os
-import cookie
+from . import cookie
__all__ = ["db", "get"]
def gennonce(length):
nonce = ""
- for i in xrange(length):
+ for i in range(length):
nonce += chr(random.randint(0, 255))
return nonce
now = int(time.time())
with self.lock:
dlist = []
- for sess in self.live.itervalues():
+ for sess in self.live.values():
if sess.atime + self.freezetime < now:
try:
if sess.dirty():
class backeddb(db):
def __init__(self, backdb, *args, **kw):
- super(backeddb, self).__init__(*args, **kw)
+ super().__init__(*args, **kw)
self.backdb = backdb
def thaw(self, sessid):
data = self.backdb[sessid]
try:
return pickle.loads(data)
- except Exception, e:
+ except:
raise KeyError()
def freeze(self, sess):