Skip to content

Commit

Permalink
🧵 Fix corountines' await
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Dec 11, 2023
1 parent e11d90e commit ace7c37
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion addon-info.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "translate-shell",
"description": "Translate text by google, bing, youdaozhiyun, haici, stardict, openai, large language model of local machine, etc at same time from CLI, GUI (GNU/Linux, Android, macOS and Windows), REPL, python, shell and vim.",
"version": "0.0.44",
"version": "0.0.45",
"author": "Wu Zhenyu <wuzhenyu@ustc.edu>",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "translate-shell",
"version": "0.0.44",
"version": "0.0.45",
"description": "Translate text by google, bing, youdaozhiyun, haici, stardict, openai, large language model of local machine, etc at same time from CLI, GUI (GNU/Linux, Android, macOS and Windows), REPL, python, shell and vim.",
"author": "Wu Zhenyu <wuzhenyu@ustc.edu>",
"license": "GPLv3",
Expand Down
13 changes: 9 additions & 4 deletions src/translate_shell/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,17 @@ async def translate_many(
:type options: dict[str, dict[str, Any]]
:rtype: None
"""
tasks = []
for translator in translators:
await asyncio.create_task(
_translate_once(
translator, translations, options.get(translator.name, {})
tasks += [
asyncio.create_task(
_translate_once(
translator, translations, options.get(translator.name, {})
)
)
)
]
for task in tasks:
await task


def translate(
Expand Down

0 comments on commit ace7c37

Please sign in to comment.