def resolve_session(self, subject_context):
if (subject_context.resolve_session() is not None):<EOL><INDENT>msg = ("<STR_LIT>")<EOL>logger.debug(msg)<EOL>return subject_context<EOL><DEDENT>try:<EOL><INDENT>session = self.resolve_context_session(subject_context)<EOL>subject_context.session = session<EOL><DEDENT>except InvalidSessionException:<EOL><INDENT>msg = ("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL>logger.debug(msg, exc_info=True)<EOL><DEDENT>return subject_context<EOL>
This method attempts to resolve any associated session based on the
context and returns a context that represents this resolved Session to
ensure it may be referenced, if needed, by the invoked do_create_subject
that performs actual ``Subject`` construction.

If there is a ``Session`` already in the context (because that is what the
caller wants to use for Subject construction) or if no session is
resolved, this method effectively does nothing, returning an
unmodified context as it was received by the method.

:param subject_context: the subject context data that may resolve a
                        Session instance
:returns: the context