Release the GIL during FileExists to ensure other Python threads in the process can make progress.
PiperOrigin-RevId: 288734867 Change-Id: I2b2f9434ee65b2563951174ade643c60cebef330
This commit is contained in:
parent
cc60597c06
commit
4e8a6a0324
@ -37,8 +37,12 @@ namespace py = pybind11;
|
|||||||
|
|
||||||
PYBIND11_MODULE(_pywrap_file_io, m) {
|
PYBIND11_MODULE(_pywrap_file_io, m) {
|
||||||
m.def("FileExists", [](const std::string& filename) {
|
m.def("FileExists", [](const std::string& filename) {
|
||||||
tensorflow::MaybeRaiseRegisteredFromStatus(
|
tensorflow::Status status;
|
||||||
tensorflow::Env::Default()->FileExists(filename));
|
{
|
||||||
|
py::gil_scoped_release release;
|
||||||
|
status = tensorflow::Env::Default()->FileExists(filename);
|
||||||
|
}
|
||||||
|
tensorflow::MaybeRaiseRegisteredFromStatus(status);
|
||||||
});
|
});
|
||||||
m.def("DeleteFile", [](const std::string& filename) {
|
m.def("DeleteFile", [](const std::string& filename) {
|
||||||
tensorflow::MaybeRaiseRegisteredFromStatus(
|
tensorflow::MaybeRaiseRegisteredFromStatus(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user