def cleanup_session(session):
 now = int(time.time())
 keys = list(session.keys())
 for key in keys:
  if (not key.startswith(u'search_')):
   continue
  value = session[key]
  if ((not isinstance(value, dict)) or (value[u'ttl'] < now)):
   del session[key]

def cleanup_session ( session ) : now = int ( time . time ( ) ) keys = list ( session . keys ( ) ) for key in keys : if ( not key . startswith ( u'search_' ) ) : continue value = session [ key ] if ( ( not isinstance ( value , dict ) ) or ( value [ u'ttl' ] < now ) ) : del session [ key ]
deletes old search results from session storage .