parameters: (self)
docstring: Clean up expired sessions.
docstring_summary: Clean up expired sessions.
docstring_tokens: Clean up expired sessions .
function: def clean_up(self):
          """Clean up expired sessions."""
  
          now = self.now()
          for _id, (data, expiration_time) in list(self.cache.items()):
              if expiration_time <= now:
                  try:
                      del self.cache[_id]
                  except KeyError:
                      pass
                  try:
                      if self.locks[_id].acquire(blocking=False):
                          lock = self.locks.pop(_id)
                          lock.release()
                  except KeyError:
                      pass
  
          # added to remove obsolete lock objects
          for _id in list(self.locks):
              locked = (
                  _id not in self.cache
                  and self.locks[_id].acquire(blocking=False)
              )
              if locked:
                  lock = self.locks.pop(_id)
                  lock.release()
function_tokens: def clean_up ( self ) : now = self . now ( ) for _id , ( data , expiration_time ) in list ( self . cache . items ( ) ) : if expiration_time <= now : try : del self . cache [ _id ] except KeyError : pass try : if self . locks [ _id ] . acquire ( blocking = False ) : lock = self . locks . pop ( _id ) lock . release ( ) except KeyError : pass # added to remove obsolete lock objects for _id in list ( self . locks ) : locked = ( _id not in self . cache and self . locks [ _id ] . acquire ( blocking = False ) ) if locked : lock = self . locks . pop ( _id ) lock . release ( )