用法:
BaseTransport.get_extra_info(name, default=None)返回有关它使用的传输或底层资源的信息。
name是一个字符串,表示要获取的transport-specific 信息。default是在信息不可用或传输不支持使用给定的第三方事件循环实现或在当前平台上查询它时返回的值。例如,以下代码尝试获取传输的底层套接字对象:
sock = transport.get_extra_info('socket') if sock is not None: print(sock.getsockopt(...))可以在某些传输上查询的信息类别:
- 插座:
'peername':套接字连接的远程地址,socket.socket.getpeername()的结果(None错误)'socket':socket.socket实例'sockname': 套接字自己的地址,socket.socket.getsockname()的结果
- SSL 套接字:
'compression':压缩算法用作字符串,如果连接未压缩,则为None;ssl.SSLSocket.compression()的结果'cipher':一个 three-value 元组,其中包含正在使用的密码的名称、定义其使用的 SSL 协议的版本以及正在使用的秘密位数;ssl.SSLSocket.cipher()的结果'peercert':对等证书;ssl.SSLSocket.getpeercert()的结果'sslcontext':ssl.SSLContext实例'ssl_object':ssl.SSLObject或ssl.SSLSocket实例
- 管道:
'pipe':管道对象
- 子流程:
'subprocess':subprocess.Popen实例
- 插座:
相关用法
- Python asyncio.shield用法及代码示例
- Python asyncio.run用法及代码示例
- Python asyncio.wait_for用法及代码示例
- Python asyncio.create_task用法及代码示例
- Python asyncio.Task.cancel用法及代码示例
- Python asyncio.loop.run_in_executor用法及代码示例
- Python asyncio.Server用法及代码示例
- Python asyncio.Server.serve_forever用法及代码示例
- Python asyncio.Event用法及代码示例
- Python asyncio.gather用法及代码示例
- Python asyncio.sleep用法及代码示例
- Python asyncio.to_thread用法及代码示例
- Python asyncio.Condition用法及代码示例
- Python asyncio.SelectorEventLoop用法及代码示例
- Python asyncio.run_coroutine_threadsafe用法及代码示例
- Python asyncio.Lock用法及代码示例
- Python asyncio.Future.add_done_callback用法及代码示例
- Python asyncio.loop.shutdown_asyncgens用法及代码示例
- Python asyncio.as_completed用法及代码示例
- Python asyncio.Semaphore用法及代码示例
注:本文由纯净天空筛选整理自python.org大神的英文原创作品 asyncio.BaseTransport.get_extra_info。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
