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

Method __exit__

gridfs/synchronous/grid_file.py:1422–1435  ·  view source on GitHub ↗

Support for the context manager protocol. Close the file if no exceptions occur and allow exceptions to propagate.

(self, exc_type: Any, exc_val: Any, exc_tb: Any)

Source from the content-addressed store, hash-verified

1420 return self
1421
1422 def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> Any:
1423 """Support for the context manager protocol.
1424
1425 Close the file if no exceptions occur and allow exceptions to propagate.
1426 """
1427 if exc_type is None:
1428 # No exceptions happened.
1429 self.close()
1430 else:
1431 # Something happened, at minimum mark as closed.
1432 object.__setattr__(self, "_closed", True)
1433
1434 # propagate exceptions
1435 return False
1436
1437
1438GRIDOUT_BASE_CLASS = io.IOBase if _IS_SYNC else object # type: Any

Callers

nothing calls this directly

Calls 2

closeMethod · 0.95
__setattr__Method · 0.45

Tested by

no test coverage detected