<s> from socketpool import ConnectionPool <EOL> from restkit . conn import Connection <EOL> _default_session = { } <EOL> def get_session ( backend_name , ** options ) : <EOL> global _default_session <EOL> if not _default_session : <EOL> _default_session = { } <EOL> pool = ConnectionPool ( factory = Connection , <EOL> backend = backend_name , ** options ) <EOL> _default_session [ backend_name ] = pool <EOL> else : <EOL> if backend_name not in _default_session : <EOL> pool = ConnectionPool ( factory = Connection , <EOL> backend = backend_name , ** options ) <EOL> _default_session [ backend_name ] = pool <EOL> else : <EOL> pool = _default_session . get ( backend_name ) <EOL> return pool <EOL> def set_session ( backend_name , ** options ) : <EOL> global _default_session <EOL> if not _default_session : <EOL> _default_session = { } <EOL> if backend_name in _default_session : <EOL> pool = _default_session . get ( backend_name ) <EOL> else : <EOL> pool = ConnectionPool ( factory = Connection , <EOL> backend = backend_name , ** options ) <EOL> _default_session [ backend_name ] = pool <EOL> return pool </s>
