博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
select – Wait for I/O Efficiently¶
阅读量:6657 次
发布时间:2019-06-25

本文共 1269 字,大约阅读时间需要 4 分钟。

select – Wait for I/O Efficiently

Purpose: Wait for notification that an input or output channel is ready.
Available In: 1.4 and later

The module provides access to platform-specific I/O monitoring functions. The most portable interface is the POSIX function , which is available on Unix and Windows. The module also includes poll(), a Unix-only API, and several options that only work with specific variants of Unix.

select()

Python’s function is a direct interface to the underlying operating system implementation. It monitors sockets, open files, and pipes (anything with a fileno() method that returns a valid file descriptor) until they become readable or writable, or a communication error occurs. makes it easier to monitor multiple connections at the same time, and is more efficient than writing a polling loop in Python using socket timeouts, because the monitoring happens in the operating system network layer, instead of the interpreter.

Note

Using Python’s file objects with works for Unix, but is not supported under Windows.

The echo server example from the section can be extended to watch for more than one connection at a time by using . The new version starts out by creating a non-blocking TCP/IP socket and configuring it to listen on an address.

转载地址:http://puqto.baihongyu.com/

你可能感兴趣的文章
功能测试
查看>>
二维数组作为函数参数传递剖析(C语言)(6.19更新第5种)
查看>>
扩展ViewFlow避免和ViewPager滑动冲突,同时支持无限循环,并完美和CircleFlowIndicator结合...
查看>>
径向基(RBF)神经网络python实现
查看>>
远程数据库备份解决方案
查看>>
“添加到收藏夹”功能(share)
查看>>
【转】Duplicate Elimination in Scrapy
查看>>
jQuery学习笔记:CSS
查看>>
System.Data.SQLite类Dll下载地址和移植C# SQLite
查看>>
NHibernate.Validator 实体验证框架
查看>>
Git中当add错误的时候怎么办?
查看>>
微型项目实践(2):用测试驱动代码生成
查看>>
【读书笔记《Android游戏编程之从零开始》】10.游戏开发基础(View 游戏框架)...
查看>>
linux 编译安装nginx
查看>>
C# 有关文件路径的操作
查看>>
如何使用Case进行简单判断
查看>>
WinForm 之Control.Invoke 和Control.BeginInvoke 方法的使用
查看>>
iBATIS.net的OR映射篇
查看>>
Node.js 2017.11.5-2017.11.16期间制作的图片爬虫总结
查看>>
C# 扩展方法[学习]
查看>>