Skip to content

Commit

Permalink
Context manager fixes
Browse files Browse the repository at this point in the history
Summary: This diff addresses some context manager methods issues.

Differential Revision: D68341672

fbshipit-source-id: a3e920ca9c4b850e7100810e3f65a99a22a1541c
  • Loading branch information
Georges Berenger authored and facebook-github-bot committed Jan 17, 2025
1 parent 485fe29 commit bea39c4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions csrc/reader/VRSReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1204,14 +1204,11 @@ void pybind_vrsreader(py::module& m) {
.def("purge_file_cache", &PyVRSReader::purgeFileCache)
.def(
"__enter__",
[&](PyVRSReader& r) { return &r; },
[](PyVRSReader& r) { return &r; },
"Enter the runtime context related to this VRSReader")
.def(
"__exit__",
[&](PyVRSReader& r,
pybind11::object* exc_type,
pybind11::object* exc_value,
pybind11::object* traceback) { r.close(); },
[](PyVRSReader& r, const py::args&) { r.close(); },
"Exit the runtime context related to this VRSReader");
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion pyvrs/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def __enter__(self) -> "VRSReader":
"""Context manager entry point."""
return self

def __exit__(self) -> None:
def __exit__(self, type, value, traceback) -> None:
"""Context manager exit point."""
self.close()

Expand Down

0 comments on commit bea39c4

Please sign in to comment.