def RedisSession(redis_conn, session_expiry=False, with_lock=False, db=None):
 locker.acquire()
 try:
  instance_name = ('redis_instance_' + current.request.application)
  if (not hasattr(RedisSession, instance_name)):
   setattr(RedisSession, instance_name, RedisClient(redis_conn, session_expiry=session_expiry, with_lock=with_lock))
  return getattr(RedisSession, instance_name)
 finally:
  locker.release()

def RedisSession ( redis_conn , session_expiry = False , with_lock = False , db = None ) : locker . acquire ( ) try : instance_name = ( 'redis_instance_' + current . request . application ) if ( not hasattr ( RedisSession , instance_name ) ) : setattr ( RedisSession , instance_name , RedisClient ( redis_conn , session_expiry = session_expiry , with_lock = with_lock ) ) return getattr ( RedisSession , instance_name ) finally : locker . release ( )
usage example: put in models:: from gluon .