(s: str)
| 345 | |
| 346 | @retry(wait=wait_fixed(1)) |
| 347 | def worker(s: str): # 多线程翻译 |
| 348 | if not s.strip() or re.match(r"^\{v\d+\}$", s): # 空白和公式不翻译 |
| 349 | return s |
| 350 | try: |
| 351 | new = self.translator.translate(s) |
| 352 | return new |
| 353 | except BaseException as e: |
| 354 | if log.isEnabledFor(logging.DEBUG): |
| 355 | log.exception(e) |
| 356 | else: |
| 357 | log.exception(e, exc_info=False) |
| 358 | raise e |
| 359 | with concurrent.futures.ThreadPoolExecutor( |
| 360 | max_workers=self.thread |
| 361 | ) as executor: |