Skip to content

Commit

Permalink
クローズしててもDropが警告を出すのを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
qryxip committed Sep 17, 2024
1 parent dfc5002 commit 695c0a9
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions crates/voicevox_core_python_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,15 @@ impl<T: 'static, C: PyTypeInfo> Closable<T, C, Tokio> {

impl<T: 'static, C: PyTypeInfo, A: Async> Drop for Closable<T, C, A> {
fn drop(&mut self) {
warn!(
"デストラクタにより`{}`のクローズが行われます。可能な限り`{}`でクローズするようにして\
下さい",
C::NAME,
A::EXIT_METHOD
);
*self.content.blocking_write_() = MaybeClosed::Closed;
let content = mem::replace(&mut *self.content.blocking_write_(), MaybeClosed::Closed);
if matches!(content, MaybeClosed::Open(_)) {
warn!(
"デストラクタにより`{}`のクローズが行われました。通常は、可能な限り`{}`でクローズ\
するようにして下さい",
C::NAME,
A::EXIT_METHOD,
);
}
}
}

Expand Down

0 comments on commit 695c0a9

Please sign in to comment.