Skip to content

Commit 0a366de

Browse files
committed
fix: Address unti test hang on test_insert
Signed-off-by: Xuanwo <github@xuanwo.io>
1 parent 6ec6846 commit 0a366de

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/common/base/src/base/singleton_instance.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,20 @@ impl GlobalInstance {
112112
/// Should only be used in testing code.
113113
#[cfg(debug_assertions)]
114114
pub fn drop_testing(thread_name: &str) {
115+
use std::thread;
116+
115117
match GLOBAL.wait() {
116118
Singleton::Production(_) => {
117119
unreachable!("drop_testing should never be called on production global")
118120
}
119121
Singleton::Testing(c) => {
120-
let mut guard = c.lock();
121-
let _ = guard.remove(thread_name);
122+
let v = {
123+
let mut guard = c.lock();
124+
guard.remove(thread_name)
125+
};
126+
// We don't care about if about this container any more, just
127+
// move to another thread to make sure this call returned ASAP.
128+
thread::spawn(move || v);
122129
}
123130
}
124131
}

0 commit comments

Comments
 (0)