異常?

exception asyncio.TimeoutError?

該操作已超過規(guī)定的截止日期。

重要

這個(gè)異常與內(nèi)置 TimeoutError 異常不同。

exception asyncio.CancelledError?

該操作已被取消。

取消asyncio任務(wù)時(shí),可以捕獲此異常以執(zhí)行自定義操作。在幾乎所有情況下,都必須重新引發(fā)異常。

重要

此異常是 Exception 的子類,因此可能會被一個(gè)過于寬泛的 try..except 塊意外地阻塞:

try:
    await operation
except Exception:
    # The cancellation is broken because the *except* block
    # suppresses the CancelledError exception.
    log.log('an error has occurred')

相反,應(yīng)使用以下模式:

try:
    await operation
except asyncio.CancelledError:
    raise
except Exception:
    log.log('an error has occurred')
exception asyncio.InvalidStateError?

TaskFuture 的內(nèi)部狀態(tài)無效。

在為已設(shè)置結(jié)果值的未來對象設(shè)置結(jié)果值等情況下,可以引發(fā)此問題。

exception asyncio.SendfileNotAvailableError?

"sendfile" 系統(tǒng)調(diào)用不適用于給定的套接字或文件類型。

子類 RuntimeError

exception asyncio.IncompleteReadError?

請求的讀取操作未完全完成。

asyncio stream APIs 提出

此異常是 EOFError 的子類。

expected?

預(yù)期字節(jié)的總數(shù)( int )。

partial?

到達(dá)流結(jié)束之前讀取的 bytes 字符串。

exception asyncio.LimitOverrunError?

在查找分隔符時(shí)達(dá)到緩沖區(qū)大小限制。

asyncio stream APIs 提出

consumed?

要消耗的字節(jié)總數(shù)。