当前位置: 首页>>代码示例>>Python>>正文


Python select.KQ_EV_ERROR属性代码示例

本文整理汇总了Python中select.KQ_EV_ERROR属性的典型用法代码示例。如果您正苦于以下问题:Python select.KQ_EV_ERROR属性的具体用法?Python select.KQ_EV_ERROR怎么用?Python select.KQ_EV_ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在select的用法示例。


在下文中一共展示了select.KQ_EV_ERROR属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: poll

# 需要导入模块: import select [as 别名]
# 或者: from select import KQ_EV_ERROR [as 别名]
def poll(self, timeout):
        kevents = self._kqueue.control(None, 1000, timeout)
        events = {}
        for kevent in kevents:
            fd = kevent.ident
            if kevent.filter == select.KQ_FILTER_READ:
                events[fd] = events.get(fd, 0) | IOLoop.READ
            if kevent.filter == select.KQ_FILTER_WRITE:
                if kevent.flags & select.KQ_EV_EOF:
                    # If an asynchronous connection is refused, kqueue
                    # returns a write event with the EOF flag set.
                    # Turn this into an error for consistency with the
                    # other IOLoop implementations.
                    # Note that for read events, EOF may be returned before
                    # all data has been consumed from the socket buffer,
                    # so we only check for EOF on write events.
                    events[fd] = IOLoop.ERROR
                else:
                    events[fd] = events.get(fd, 0) | IOLoop.WRITE
            if kevent.flags & select.KQ_EV_ERROR:
                events[fd] = events.get(fd, 0) | IOLoop.ERROR
        return events.items() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:24,代码来源:kqueue.py

示例2: testPair

# 需要导入模块: import select [as 别名]
# 或者: from select import KQ_EV_ERROR [as 别名]
def testPair(self):
        kq = select.kqueue()
        a, b = socket.socketpair()

        a.send(b'foo')
        event1 = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE)
        event2 = select.kevent(b, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE)
        r = kq.control([event1, event2], 1, 1)
        self.assertTrue(r)
        self.assertFalse(r[0].flags & select.KQ_EV_ERROR)
        self.assertEqual(b.recv(r[0].data), b'foo')

        a.close()
        b.close()
        kq.close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:test_kqueue.py

示例3: poll

# 需要导入模块: import select [as 别名]
# 或者: from select import KQ_EV_ERROR [as 别名]
def poll(self,
                 timeout,
                 _len=len,
                 _READ=select.KQ_FILTER_READ,
                 _WRITE=select.KQ_FILTER_WRITE,
                 _EOF=select.KQ_EV_EOF,
                 _ERROR=select.KQ_EV_ERROR):
            try:
                kevents = self._kqueue.control(None, _len(self.socket_map),
                                               timeout)
            except OSError as err:
                if err.errno == errno.EINTR:
                    return
                raise
            for kevent in kevents:
                inst = self.socket_map.get(kevent.ident)
                if inst is None:
                    continue
                if kevent.filter == _READ:
                    if inst.readable():
                        _read(inst)
                if kevent.filter == _WRITE:
                    if kevent.flags & _EOF:
                        # If an asynchronous connection is refused,
                        # kqueue returns a write event with the EOF
                        # flag set.
                        # Note that for read events, EOF may be returned
                        # before all data has been consumed from the
                        # socket buffer, so we only check for EOF on
                        # write events.
                        inst.handle_close()
                    else:
                        if inst.writable():
                            _write(inst)
                if kevent.flags & _ERROR:
                    inst.handle_close()


# ===================================================================
# --- choose the better poller for this platform
# =================================================================== 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:43,代码来源:ioloop.py

示例4: poll

# 需要导入模块: import select [as 别名]
# 或者: from select import KQ_EV_ERROR [as 别名]
def poll(self, timeout):
        kevents = self._kqueue.control(None, 1000, timeout)
        events = {}
        for kevent in kevents:
            fd = kevent.ident
            flags = 0
            if kevent.filter == select.KQ_FILTER_READ:
                events[fd] = events.get(fd, 0) | IOLoop.READ
            if kevent.filter == select.KQ_FILTER_WRITE:
                events[fd] = events.get(fd, 0) | IOLoop.WRITE
            if kevent.flags & select.KQ_EV_ERROR:
                events[fd] = events.get(fd, 0) | IOLoop.ERROR
        return events.items() 
开发者ID:omererdem,项目名称:honeything,代码行数:15,代码来源:ioloop.py

示例5: start

# 需要导入模块: import select [as 别名]
# 或者: from select import KQ_EV_ERROR [as 别名]
def start(self):
		while True:
			eventlist = self.kq.control(None, 100, 1)
			for event in eventlist:
				send = True
				if event.flags & select.KQ_EV_ERROR:
					send = self.onSocketEvent(event.ident, sockConnect.socketEventExcept)
				elif event.filter == select.KQ_FILTER_READ:
					send = self.onSocketEvent(event.ident, sockConnect.socketEventCanRecv)
				elif event.filter == select.KQ_FILTER_WRITE:
					if event.flags & select.KQ_EV_EOF:
						send = self.onSocketEvent(event.ident, sockConnect.socketEventExcept)
					else:
						send = self.onSocketEvent(event.ident, sockConnect.socketEventCanSend)
				if not send:
					try:
						self.kq.control([select.kevent(event.ident, filter=select.KQ_FILTER_WRITE,
												flags=select.KQ_EV_DELETE)], 0)
					except:
						pass
					try:
						self.kq.control([select.kevent(event.ident, filter=select.KQ_FILTER_READ,
												flags=select.KQ_EV_DELETE)], 0)
					except:
						pass
			self._handlerCallback() 
开发者ID:wdongxv,项目名称:DDDProxy,代码行数:28,代码来源:baseServer.py


注:本文中的select.KQ_EV_ERROR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。