refactor: replace runtime_error with TORCH_CHECK for better error handling (#163628)

Fixes some parts of issue #148114

@pytorchbot label "topic: not user facing"

@FFFrog PTAL
Pull Request resolved: https://github.com/pytorch/pytorch/pull/163628
Approved by: https://github.com/albanD
This commit is contained in:
lichuyang
2025-10-16 11:09:44 +00:00
committed by PyTorch MergeBot
parent 69b05913fb
commit f06e669f6c

View File

@ -500,9 +500,9 @@ static void child_atfork() {
bool THPEngine_initModule(PyObject* module) {
#ifndef _WIN32
if (pthread_atfork(nullptr, nullptr, child_atfork) != 0) {
TORCH_CHECK(false, "unable to set pthread_atfork handler");
}
TORCH_CHECK(
pthread_atfork(nullptr, nullptr, child_atfork) == 0,
"unable to set pthread_atfork handler");
#endif
if (PyType_Ready(&THPEngineType) < 0)
return false;