fix: Fix parameter mismatch in EPUBBookLoaderHelper.translate_with_ba… (#429)

* fix: Fix parameter mismatch in EPUBBookLoaderHelper.translate_with_backoff

- Fix TypeError when calling translate_with_backoff with multiple arguments
- Add proper parameter handling in the decorated method
- Add jitter=None to prevent extra parameters from backoff decorator
- Improve code readability and error handling

* style: format code with black

---------

Co-authored-by: wenping <angenpn@gmail.com>
This commit is contained in:
anenin 2024-11-06 18:09:09 +08:00 committed by GitHub
parent 546fbd8e37
commit e962a08f35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,7 +1,7 @@
import re
from copy import copy
import backoff
import logging
from copy import copy
logging.basicConfig(level=logging.WARNING)
logger = logging.getLogger(__name__)
@ -37,9 +37,10 @@ class EPUBBookLoaderHelper:
Exception,
on_backoff=lambda details: logger.warning(f"retry backoff: {details}"),
on_giveup=lambda details: logger.warning(f"retry abort: {details}"),
jitter=None,
)
def translate_with_backoff(self, **kwargs):
return self.translate_model.translate(**kwargs)
def translate_with_backoff(self, text, context_flag=False):
return self.translate_model.translate(text, context_flag)
def deal_new(self, p, wait_p_list, single_translate=False):
self.deal_old(wait_p_list, single_translate, self.context_flag)