您现在的位置是:首页 >技术交流 >一图看懂 async_timeout 模块:异步 I/O 的超时设置,资料整理+笔记(大全)网站首页技术交流
一图看懂 async_timeout 模块:异步 I/O 的超时设置,资料整理+笔记(大全)
本文由 大侠(AhcaoZhu)原创,转载请声明。
链接: https://blog.csdn.net/Ahcao2008
一图看懂 async_timeout 模块:异步 I/O 的超时设置,资料整理+笔记(大全)
?摘要
- 全文介绍python的 async_timeout 模块(异步 I/O 的超时设置)、函数、类及类的方法和属性。
- 它通过代码抓取并经AI智能翻译和人工校对。
- 是一部不可多得的权威字典类工具书。它是系列集的一部分。后续陆续发布、敬请关注。【原创:AhcaoZhu大侠】
?模块图
async_timeout
◆asyncio
?类关系图
◆object
◆BaseException
◆Exception
◆EOFError
◆asyncio.streams.IncompleteReadError
◆RuntimeError
◆asyncio.events.SendfileNotAvailableError
◆asyncio.queues.QueueEmpty
◆asyncio.queues.QueueFull
◆asyncio.streams.LimitOverrunError
◆concurrent.futures._base.Error
◆asyncio.base_futures.InvalidStateError
◆_asyncio.Future
◆_asyncio.Task
async_timeout.timeout
◆asyncio.events.AbstractEventLoop
◆asyncio.base_events.BaseEventLoop
◆asyncio.proactor_events.BaseProactorEventLoop
◆asyncio.windows_events.ProactorEventLoop
◆asyncio.selector_events.BaseSelectorEventLoop
◆asyncio.windows_events._WindowsSelectorEventLoop
◆asyncio.events.AbstractEventLoopPolicy
◆asyncio.events.BaseDefaultEventLoopPolicy
◆asyncio.windows_events.WindowsProactorEventLoopPolicy
◆asyncio.windows_events.WindowsSelectorEventLoopPolicy
◆asyncio.events.AbstractServer
◆asyncio.events.Handle
◆asyncio.events.TimerHandle
◆asyncio.locks.Event
◆asyncio.locks._ContextManagerMixin
◆asyncio.locks.Condition
◆asyncio.locks.Lock
◆asyncio.locks.Semaphore
◆asyncio.locks.BoundedSemaphore
◆asyncio.protocols.BaseProtocol
◆asyncio.protocols.BufferedProtocol
◆asyncio.protocols.DatagramProtocol
◆asyncio.protocols.Protocol
◆asyncio.streams.FlowControlMixin
◆asyncio.streams.StreamReaderProtocol
◆asyncio.protocols.SubprocessProtocol
◆asyncio.queues.Queue
◆asyncio.queues.LifoQueue
◆asyncio.queues.PriorityQueue
◆asyncio.streams.StreamReader
◆asyncio.streams.StreamWriter
◆asyncio.transports.BaseTransport
◆asyncio.transports.DatagramTransport
◆asyncio.transports.ReadTransport
◆asyncio.transports.Transport
◆asyncio.transports.SubprocessTransport
◆asyncio.transports.WriteTransport
◆asyncio.transports.ReadTransport
◆asyncio.windows_events.IocpProactor
?模块全展开
☘️【async_timeout】
async_timeout, fullname=async_timeout, file=async_timeout_init_.py
?统计
序号 | 类别 | 数量 |
---|---|---|
2 | bool | 1 |
4 | str | 5 |
6 | list | 1 |
8 | dict | 1 |
9 | module | 2 |
10 | class | 2 |
11 | function | 1 |
13 | residual | 6 |
14 | system | 10 |
16 | all | 19 |
?常量
?bool
1 PY_37 True
?模块
?2 asyncio
asyncio, fullname=asyncio, file=asyncio_init_.py
?3 sys
sys, fullname=sys
?函数
?4 current_task(loop: asyncio.events.AbstractEventLoop) -> ‘asyncio.Task[Any]’
current_task(loop: asyncio.events.AbstractEventLoop) -> ‘asyncio.Task[Any]’, module=async_timeout, line:105 at site-packagesasync_timeout_init_.py
?类
?5 traceback
traceback, traceback, module=builtins
TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)
创建一个新的traceback对象。
data
1 tb_frame=<member ‘tb_frame’ of ‘traceback’ objects> kind:data type:member_descriptor class:<class ‘traceback’>
2 tb_lasti=<member ‘tb_lasti’ of ‘traceback’ objects> kind:data type:member_descriptor class:<class ‘traceback’>
3 tb_lineno=<member ‘tb_lineno’ of ‘traceback’ objects> kind:data type:member_descriptor class:<class ‘traceback’>
4 tb_next=<attribute ‘tb_next’ of ‘traceback’ objects> kind:data type:getset_descriptor class:<class ‘traceback’>
?6 async_timeout.timeout
timeout, async_timeout.timeout, module=async_timeout, line:13 at site-packagesasync_timeout_init_.py
超时上下文管理器。
当您想要在代码块周围应用超时逻辑或在 asyncio.wait_for 并不合适。例如:
>>> with timeout(0.001):
... async with aiohttp.get('https://github.com') as r:
... await r.text()
timeout - 以秒为单位的值或None来禁用超时逻辑循环
loop - 兼容的事件循环
property
1 expired=<property object at 0x000001C17F000138> kind:property type:property class:<class ‘async_timeout.timeout’>
2 remaining=<property object at 0x000001C17F0BD908> kind:property type:property class:<class ‘async_timeout.timeout’>
?剩余
7 doc
8 loader <_frozen_importlib_external.SourceFileLoader object at 0x000001C17EFC1108>
9 spec ModuleSpec(name=‘async_timeout’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x000001C17EFC1108>, origin=‘…libsite-packagesasync_timeoutinit.py’, submodule_search_locations=[‘…libsite-packagesasync_timeout’])
10 Optional typing.Optional
11 Type typing.Type
12 Any typing.Any
☘️【asyncio】
asyncio, fullname=asyncio, file=asyncio_init_.py
☘️【sys】
sys, fullname=sys