Return a session to the pool.

        Never blocks:  if the pool is full, the returned session is
        discarded.

        :type session: :class:`~google.cloud.spanner_v1.session.Session`
        :param session: the session being returned.
503877
def put(self, session):
        
        try:
            self._sessions.put_nowait(session)
        except queue.Full:
            try:
                session.delete()
            except NotFound:
                pass
690304
def session(self, session=None):
        '''
        '''
        if self.related_instance:
            session = self.related_instance.session
        # we have a session, we either create a new one return the same session
        if session is None:
            raise QuerySetError('Related manager can be accessed only from\
 a loaded instance of its related model.')
        return session
878678
def do_get_session(self, session_key):
        
        session_id = session_key.session_id
        msg = ("do_get_session: Attempting to retrieve session with key " +
               str(session_id))
        logger.debug(msg)

        session = self._retrieve_session(session_key)

        if (session is not None):
            self.validate(session, session_key)

        return session
144046
def clear(self, session):
        
        try:
            sess = self.sessions[session]
        except KeyError:
            return constants.StatusCode.error_invalid_object
        return sess.clear()
1264149
def _get_session():
    """"""
    session = getattr(g, '_session', None)
    if session is None:
        session = g._session = db.session()
    return session
963805
def http_session(self):
        
        if self._http_session is None:
            session = VerboseHTTPSession()
            session.headers.update(self.DEFAULT_HTTP_HEADERS)
            self._http_session = session
        return self._http_session
775496
def session(self):
        
        ret = self.session_class(
            client_id=self._client_id,
            client=self.client,
            auto_refresh_url=self.auto_refresh_url,
            auto_refresh_kwargs=self.auto_refresh_kwargs,
            scope=self.scope,
            state=self.state,
            blueprint=self,
            base_url=self.base_url,
            **self.kwargs
        )

        def token_updater(token):
            self.token = token

        ret.token_updater = token_updater
        return self.session_created(ret)
131709
def login(self, session=None):
        
        session = session or self.client.session
        try:
            response = session.get(self.login_url)
        except ConnectionError:
            raise APIError(None, self.login_url, None, 'ConnectionError')
        except Exception as e:
            raise APIError(None, self.login_url, None, e)
        app_key = re.findall(r'''"appKey":\s"(.*?)"''', response.text)
        if app_key:
            self.app_key = app_key[0]
        else:
            raise RaceCardError("Unable to find appKey")
1194486
def fetchone(self):
        
        row = self._session.fetchone()
        if row:
            return self._row_factory(row)
202771
def client(*args, loop=None, **kwargs):
    
    return _get_default_session(loop=loop).client(*args, **kwargs)
794175
def _ReturnConnection(self):
		
		if self.conn is not None:
			if self.connInfo.commitOnEnd is True or self.commitOnEnd is True:
				self.conn.Commit()
					
			Pool().returnConnection(self.conn)
			self.conn = None
855155
def get(self):
        
        try:
            session = self._sessions.get_nowait()
        except queue.Empty:
            session = self._new_session()
            session.create()
        else:
            if not session.exists():
                session = self._new_session()
                session.create()
        return session
493134
def get_session(self):
        
        response = _request_access_token(
            grant_type=auth.CLIENT_CREDENTIALS_GRANT,
            client_id=self.client_id,
            client_secret=self.client_secret,
            scopes=self.scopes,
        )

        oauth2credential = OAuth2Credential.make_from_response(
            response=response,
            grant_type=auth.CLIENT_CREDENTIALS_GRANT,
            client_id=self.client_id,
            client_secret=self.client_secret,
        )

        return Session(oauth2credential=oauth2credential)
117017
def session(self) -> SessionT:
        ''''''
        session = self._session_class()(
            connection_pool=self._connection_pool,
        )
        self.event_dispatcher.notify(self.ClientEvent.new_session, session)
        return session
1292635
def sessions(session):
    
    active_sessions = session.get_sessions()
    if not active_sessions:
        click.echo('(No active sessions)')
        return
    for active_session in active_sessions:
        click.echo(active_session)
1117503
def getReadSession(self):
        '''  '''
        if self.ReadSession is None:
            self.ReadSession=scoped_session(sessionmaker(bind=self.engine))

        return self.ReadSession
402161
def _init_session(self, session):
        # type: (requests.Session) -> None
        
        _patch_redirect(session)

        # Change max_retries in current all installed adapters
        max_retries = self.config.retry_policy()
        for protocol in self._protocols:
            session.adapters[protocol].max_retries = max_retries