Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1102067
  • 博文数量: 170
  • 博客积分: 1603
  • 博客等级: 上尉
  • 技术积分: 1897
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-09 15:54
文章分类

全部博文(170)

文章存档

2016年(27)

2015年(21)

2014年(27)

2013年(21)

2012年(7)

2011年(67)

我的朋友

分类: Python/Ruby

2014-11-07 09:54:52

上来就遇到个大问题,一段代码看不明白

点击(此处)折叠或打开

  1. r, w, e = _eintr_retry(select.select, [self], [], [],
  2.                                        poll_interval)

点击(此处)折叠或打开

  1. def _eintr_retry(func, *args):
  2.     """restart a system call interrupted by EINTR"""
  3.     while True:
  4.         try:
  5.             return func(*args)
  6.         except (OSError, select.error) as e:
  7.             if e.args[0] != errno.EINTR:
  8.                 raise

平时select不都是穿socket进去的么,这传个self,select是怎么识别的
可以识别的话,self的类肯定有个特别的函数能让select用,翻select.py没用,还好网上找到了答案
http://blog.chinaunix.net/uid-20135217-id-3291038.html

“select函数的参数是3个列表,包含整数文件描述符,或者带有可返回文件描述符的fileno()方法对象。”
果然类里有fileno()函数返回socket.fileno()

待续

补充...这个模块没待续了,太简单轻量了完全没什么用
有需要学习twisted模块.....
顺便保底转载个
http://blog.sina.com.cn/s/blog_704b6af70100py9n.html
阅读(1789) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~