connection.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:ave 作者: sonyxperiadev 项目源码 文件源码
def write(self, payload, timeout=None):
        size  = len(payload)
        done  = 0
        limit = None
        if timeout != None: # first and last test of 'timeout'
            limit = time.time() + timeout
        while done < size:
            try:
                done += Connection.write(self, payload[done:])
            except ConnectionAgain:
                if limit:
                    timeout == limit - time.time()
                else:
                    timeout = -1
                events = self.poll(select.POLLOUT, timeout)
                if not events:
                    raise ConnectionTimeout('write attempt timed out')
                if events[0][1] & (select.POLLHUP | select.POLLERR):
                    raise ConnectionClosed(
                        'write attempt failed with %d at %d %f'
                        % (events[0][1], done, timeout)
                    )
                if events[0][1] & select.POLLOUT:
                    continue
                raise Exception('unknown events: %s' % events)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号