MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / validate_session

Method validate_session

pymongo/synchronous/pool.py:532–541  ·  view source on GitHub ↗

Validate this session before use with client. Raises error if the client is not the one that created the session.

(
        self, client: Optional[MongoClient[Any]], session: Optional[ClientSession]
    )

Source from the content-addressed store, hash-verified

530 )
531
532 def validate_session(
533 self, client: Optional[MongoClient[Any]], session: Optional[ClientSession]
534 ) -> None:
535 """Validate this session before use with client.
536
537 Raises error if the client is not the one that created the session.
538 """
539 if session:
540 if session._client is not client:
541 raise InvalidOperation("Can only use session with the MongoClient that started it")
542
543 def close_conn(self, reason: Optional[str]) -> None:
544 """Close this connection with a reason."""

Callers 5

commandMethod · 0.95
use_commandMethod · 0.45
use_commandMethod · 0.45
_execute_commandMethod · 0.45
_execute_commandMethod · 0.45

Calls 1

InvalidOperationClass · 0.90

Tested by

no test coverage detected