def get_session(self): db = Database() session = db.get_session() self.log(session["timestamp"]) #b = session["timestamp"] sess_datetime = session["timestamp"] if session['timestamp'] is None or (datetime.utcnow() - sess_datetime) > timedelta(minutes=14) : sessionlist = self.create_session() db.update_session(*sessionlist) session = db.get_session() self.log("needs new "+session["key"]+" expires: "+str(session["timestamp"] + timedelta(0, 0, 0, 0, 15))) return session["key"] else: self.log("old "+session["key"]+" expires: "+str(session["timestamp"] + timedelta(minutes=15))) return session["key"]
def get_session(self): db = Database() session = db.get_session() self.log(session['timestamp']) sess_datetime = session['timestamp'] if session['timestamp'] is None or datetime.utcnow() \ - sess_datetime > timedelta(minutes=14): sessionlist = self.create_session() db.update_session(*sessionlist) session = db.get_session() self.log('needs new ' + session['key'] + ' expires: ' + str(session['timestamp'] + timedelta(0, 0, 0, 0, 15))) return session['key'] else: self.log('old ' + session['key'] + ' expires: ' + str(session['timestamp'] + timedelta(minutes=15))) return session['key']