Skip to content

Commit 100a911

Browse files
author
ilia-cher
committed
Show errors from the tasks in the thread pool
Summary: Making sure we don't silently ignore exceptions from the tasks in the thread pool Test Plan: python setup.py clean && python setup.py develop install ghstack-source-id: 2a91fbf Pull Request resolved: #33938
1 parent f5f1e5e commit 100a911

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

c10/core/thread_pool.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include <c10/core/thread_pool.h>
22

3+
#include <c10/util/Logging.h>
4+
35
namespace c10 {
46

57
ThreadPool::ThreadPool(
@@ -108,7 +110,10 @@ void ThreadPool::main_loop(std::size_t index) {
108110
} else {
109111
tasks.no_id();
110112
}
111-
} catch (const std::exception&) {
113+
} catch (const std::exception& e) {
114+
C10_LOG_EVERY_MS(ERROR, 1000) << "Exception in thread pool task: " << e.what();
115+
} catch (...) {
116+
C10_LOG_EVERY_MS(ERROR, 1000) << "Exception in thread pool task: unknown";
112117
}
113118

114119
// Update status of empty, maybe

0 commit comments

Comments
 (0)