Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [Python] すべてのPyO3クラスをfrozenに #1041

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

qryxip
Copy link
Member

@qryxip qryxip commented Mar 8, 2025

内容

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 以降に初めて問題になるやつでしたね。

@qryxip qryxip requested a review from Hiroshiba March 8, 2025 13:10
Copy link
Member

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

0.16に入れたいor入れないといけない系ですかね?
であればマージいただけると!!
そうじゃない場合はしばらくマージを待って、release-0.16ができてからmainにマージするのが良いかなと!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants