Skip to content

🌐 Add Chinese translation for docs/zh/docs/async.md #3830

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

Conversation

jaystone776
Copy link
Contributor

as title

@codecov
Copy link

codecov bot commented Sep 1, 2021

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cf73051) 100.00% compared to head (c2c9b7d) 100.00%.
Report is 1086 commits behind head on master.

❗ Current head c2c9b7d differs from pull request most recent head 99fac02. Consider uploading reports for the commit 99fac02 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##            master     #3830     +/-   ##
===========================================
  Coverage   100.00%   100.00%             
===========================================
  Files          540       410    -130     
  Lines        13969     10281   -3688     
===========================================
- Hits         13969     10281   -3688     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2021

📝 Docs preview for commit 8769b34 at: https://612efbdca2fbfe444dff1c9c--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit c2c9b7d at: https://613ebc557ec3e2f4558a0dab--fastapi.netlify.app

@tiangolo tiangolo changed the title Add Chinese Translation for docs\async.md 🌐 Add Chinese translation for docs/async.md Oct 5, 2021
@tiangolo tiangolo added awaiting-review lang-all Translations lang-zh Chinese translations labels Oct 5, 2021
@github-actions github-actions bot mentioned this pull request Oct 5, 2021

---

如果使用不支持 `await` 的第三方支持库与(数据库、API、文件系统等)对象通信,(这是绝大多数数据库支持库的现状),就要只能使用 `def` 把*路径操作函数*声明为普通函数,如下:
Copy link

Choose a reason for hiding this comment

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

“就要只能使用”是什么意思?是想说"就只能使用"吗


**协程**只是个非常花哨的术语,指的是由 `async def` 函数返回的对象。Python 把它识别为可以在某些点启动或终止的函数,但它还可以在内部暂停 ⏸,只要在它的内部包含 `await`。

但是使用 `async` 与 `await` 的异步编码的这种功能尝尝被统称为“携程”。它与 Go 的核心功能 “Goroutines” 相对应。
Copy link
Contributor

Choose a reason for hiding this comment

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

“携程” -> “协程”

Suggested change
但是使用 `async``await` 的异步编码的这种功能尝尝被统称为“携程”。它与 Go 的核心功能 “Goroutines” 相对应。
但是使用 `async``await` 的异步编码的这种功能尝尝被统称为“协程”。它与 Go 的核心功能 “Goroutines” 相对应。


使用普通 `def` 替代 `async def` 声明*路径操作函数*时,要在等待的外部线程池中运行,不能直接调用(因为它会阻塞服务器)。

如果你之前使用的异步框架不以上述方式运行,或者你习惯了定义琐碎的仅供计算的纯 `def` *路径操作函数*只为了提升些许性能(约 100 纳秒),请注意,在 **FastAPI** 中的效果正相反。在这些情况下,除非*路径操作函数*使用执行阻塞 <abbr title="输入/输出:磁盘读取与写入,网络通信d。">I/O</abbr> 的代码,最好使用 `async def`。
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
如果你之前使用的异步框架不以上述方式运行,或者你习惯了定义琐碎的仅供计算的纯 `def` *路径操作函数*只为了提升些许性能(约 100 纳秒),请注意,在 **FastAPI** 中的效果正相反。在这些情况下,除非*路径操作函数*使用执行阻塞 <abbr title="输入/输出:磁盘读取与写入,网络通信d。">I/O</abbr> 的代码,最好使用 `async def`
如果你之前使用的异步框架不以上述方式运行,或者你习惯了定义琐碎的仅供计算的普通`def` *路径操作函数*而只为了提升些许性能(约 100 纳秒),请注意,在 **FastAPI** 中的效果正相反。在这些情况下,最好使用 `aysnc def`除非*路径操作函数*使用阻塞式 <abbr title="输入/输出:磁盘读取与写入,网络通信">I/O</abbr> 的代码。

tiangolo and others added 2 commits June 27, 2023 01:39

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@tiangolo
Copy link
Member

📝 Docs preview for commit 99fac02 at: https://649a2380c3bf901b5aa9e53c--fastapi.netlify.app

@tiangolo tiangolo changed the title 🌐 Add Chinese translation for docs/async.md 🌐 Add Chinese translation for docs/zh/docs/async.md Jun 27, 2023
@tiangolo
Copy link
Member

Thank you! It seems this one was handled in another PR, so I'll pass on this one, but feel free to add new PRs updating the current version if you think that's needed!

Thanks! ☕ 🍰

@tiangolo tiangolo closed this Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved-1 lang-all Translations lang-zh Chinese translations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants