mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
fix backend not deallocating due to circular reference
This commit is contained in:
parent
e9f4ac0e14
commit
a8e6fbd0fd
1 changed files with 6 additions and 7 deletions
|
@ -176,6 +176,11 @@ def proto_progress_to_native(progress: pb.Progress) -> Progress:
|
|||
else:
|
||||
assert_impossible_literal(kind)
|
||||
|
||||
def _on_progress(progress_bytes: bytes) -> bool:
|
||||
progress = pb.Progress()
|
||||
progress.ParseFromString(progress_bytes)
|
||||
native_progress = proto_progress_to_native(progress)
|
||||
return hooks.bg_thread_progress_callback(True, native_progress)
|
||||
|
||||
class RustBackend:
|
||||
def __init__(
|
||||
|
@ -191,13 +196,7 @@ class RustBackend:
|
|||
log_path=log_path,
|
||||
)
|
||||
self._backend = ankirspy.open_backend(init_msg.SerializeToString())
|
||||
self._backend.set_progress_callback(self._on_progress)
|
||||
|
||||
def _on_progress(self, progress_bytes: bytes) -> bool:
|
||||
progress = pb.Progress()
|
||||
progress.ParseFromString(progress_bytes)
|
||||
native_progress = proto_progress_to_native(progress)
|
||||
return hooks.bg_thread_progress_callback(True, native_progress)
|
||||
self._backend.set_progress_callback(_on_progress)
|
||||
|
||||
def _run_command(
|
||||
self, input: pb.BackendInput, release_gil: bool = False
|
||||
|
|
Loading…
Reference in a new issue