Skip to Content
Python 技術手冊 第三版
book

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate to advanced content levelIntermediate to advanced
856 pages
17h 17m
Chinese
GoTop Information, Inc.
Content preview from Python 技術手冊 第三版
582
|
18 章 非同步的替代方案
最後,所有類型的 async 架構通常也可能支援稱為
futures
(有時稱為
promises
deferreds
)的物件,類似於表 14-1 中所涵蓋的那些(不過後者
仰賴執行緒或行程的集區,而 async futures 則反映某個非阻斷式 I/O 作業
的完成)。包裹一個 coroutine 物件的 futures 只能在事件迴圈運行中的時候
執行。
asyncio 模組(僅限 v3
asyncio
模組是 v3 非同步程式設計現代做法的核心所在,特別是網路相關
的任務。標準程式庫所提供的
asyncio
專注於提供抽象層次相對低階的基
礎結構和元件。然而,你可以找到較高抽象層的模組,在這個 wiki 頁面
https://github.com/python/asyncio/wiki/ThirdParty
):像是aiohttp
https://
pypi.python.org/pypi/aiohttp
,支援 HTTP 伺服器與客戶端,包括 WebSocket
https://en.wikipedia.org/wiki/WebSocket
))之類的構建組塊、web 框架(有
些運作於
aiohttp
之上,有些則是獨立的)、AsyncSSH
http://asyncssh.
readthedocs.io/en/latest/
,支援 SSH 伺服器與客戶端),諸如此類的。
asyncio
生態系統提出貢獻
如果你發現自己正在為那個 wiki 頁面所列的模組尚未涵蓋
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

測試驅動開發|使用 Python

測試驅動開發|使用 Python

Harry J.W. Percival
Linux 内核观测技术BPF

Linux 内核观测技术BPF

David Calavera, Lorenzo Fontana

Publisher Resources

ISBN: 9789864766819