mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Use std::filesystem in c10 tempfile and tempdir (#106656)
This PR simplifies c10::TempFile and c10::TempDir. It also deletes Windows temp files in c10::~TempFile, this behavior is absent on the current version. Pull Request resolved: https://github.com/pytorch/pytorch/pull/106656 Approved by: https://github.com/ezyang
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
#include <algorithm>
|
||||
#include <cerrno>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
@ -83,7 +84,7 @@ int main(int argc, char* argv[]) {
|
||||
setsid(); // Daemonize the process
|
||||
|
||||
std::unique_ptr<ManagerServerSocket> srv_socket;
|
||||
c10::optional<c10::TempDir> tempdir;
|
||||
std::optional<c10::TempDir> tempdir;
|
||||
try {
|
||||
tempdir = c10::try_make_tempdir(/*name_prefix=*/"torch-shm-dir-");
|
||||
if (!tempdir.has_value()) {
|
||||
@ -91,7 +92,7 @@ int main(int argc, char* argv[]) {
|
||||
"could not generate a random directory for manager socket");
|
||||
}
|
||||
|
||||
std::string tempfile = tempdir->name + "/manager.sock";
|
||||
std::string tempfile = (tempdir->name / "manager.sock").string();
|
||||
|
||||
srv_socket = std::make_unique<ManagerServerSocket>(tempfile);
|
||||
register_fd(srv_socket->socket_fd);
|
||||
|
Reference in New Issue
Block a user