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 技術手冊 第三版
466
|
14 章 執行緒和行程
AsyncResult 類別
類別
Pool
的方法
apply_async
map_async
會回傳類別
AsyncResult
的一個
實體。類別
AsyncResult
的一個實體
r
提供了下列方法:
get get(timeout=None)
就緒時阻斷並回傳結果,或重新提出計算結果的過程中被提出的例外。當
timeout
不為
None
,它就是以秒為單位的浮點數值;
get
會在
timeout
秒之
後結果尚未就緒時,提出
multiprocessing.TimeoutError
ready ready()
不會阻斷;如果結果就緒,就回傳
True
,否則回傳
False
successful successful()
不會阻斷:如果結果就緒,而且計算沒有提出例外,就回傳
True
;如果計
算過程有提出一個例外,就回傳
False
。如果結果尚未就緒,
successful
就會提出
AssertionError
wait wait(timeout=None)
阻斷並等候到結果就緒為止。如果
timeout
不為
None
,它就是以秒為單
位的一個
float
:如果結果在
timeout
秒之後尚未就緒,
wait
就會提出
multiprocessing.TimeoutError
concurrent.futures 模組
concurrent
套件提供單一個模組
futures
concurrent.futures
只有在 v3
是標準程式庫的一部分;要在 v2 中使用它,就以
pip2 install futures ...
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