Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
内容
VOICEVOX CORE Python APIのクラスはすべてイミュータルなはずであり、メソッドのレシーバーに
&mut self
を使わなければならない箇所は無いはずである。にも関わらず&mut self
が使われている箇所がいくつもあり、非同期に同時にAPIを触ると次のようにコケるようになっていた。RuntimeError: Already mutably borrowed
このPRでは
&mut self
をすべて一掃し、それを確実にするためすべての#[pyclass]
にfrozen
を付ける。See-also: https://pyo3.rs/main/class#frozen-classes-opting-out-of-interior-mutability
関連 Issue
その他
#1032 を書いている途中に
await
を入れ忘れたところ偶然発見しました。直すの忘れてた…。こういうやつ他にもいくつもありそう。というか
&mut self
ってロックしたりせずにエラーになるんですね。もしかしたら最近になってからの挙動かもしれませんが。[追記] よく考えたらPython自体はGILに縛られているはずだから、 #962 以降に初めて問題になるやつでしたね。