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


Python select.KQ_EV_ENABLE属性代码示例

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


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

示例1: test_issue30058

# 需要导入模块: import select [as 别名]
# 或者: from select import KQ_EV_ENABLE [as 别名]
def test_issue30058(self):
        # changelist must be an iterable
        kq = select.kqueue()
        a, b = socket.socketpair()
        ev = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE)

        kq.control([ev], 0)
        # not a list
        kq.control((ev,), 0)
        # __len__ is not consistent with __iter__
        class BadList:
            def __len__(self):
                return 0
            def __iter__(self):
                for i in range(100):
                    yield ev
        kq.control(BadList(), 0)
        # doesn't have __len__
        kq.control(iter([ev]), 0)

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

示例2: modifyRegistrationForEvents

# 需要导入模块: import select [as 别名]
# 或者: from select import KQ_EV_ENABLE [as 别名]
def modifyRegistrationForEvents(self, asyncSocket, readEvents, writeEvents):
    fileno = asyncSocket.fileno()
    if readEvents:
      readKE = select.kevent(ident = fileno,
                             filter = select.KQ_FILTER_READ,
                             flags = select.KQ_EV_ENABLE)
    else:
      readKE = select.kevent(ident = fileno,
                             filter = select.KQ_FILTER_READ,
                             flags = select.KQ_EV_DISABLE)
    if writeEvents:
      writeKE = select.kevent(ident = fileno,
                              filter = select.KQ_FILTER_WRITE,
                              flags = select.KQ_EV_ENABLE)
    else:
      writeKE = select.kevent(ident = fileno,
                              filter = select.KQ_FILTER_WRITE,
                              flags = select.KQ_EV_DISABLE)
    # Should be able to put readKE and writeKE in a list in
    # one call to kqueue.control, but this is broken due to Python issue 5910
    self.__kqueue.control([readKE], 0, 0)
    self.__kqueue.control([writeKE], 0, 0) 
开发者ID:ActiveState,项目名称:code,代码行数:24,代码来源:recipe-577662.py

示例3: testPair

# 需要导入模块: import select [as 别名]
# 或者: from select import KQ_EV_ENABLE [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

示例4: register

# 需要导入模块: import select [as 别名]
# 或者: from select import KQ_EV_ENABLE [as 别名]
def register(self, key, f):
        BasePoller.register(self, key, f)
        r_event = select.kevent(
            f.fileno(), filter=select.KQ_FILTER_READ,
            flags=select.KQ_EV_ADD | select.KQ_EV_ENABLE)
        self.events.append(r_event)
        w_event = select.kevent(
            f.fileno(), filter=select.KQ_FILTER_WRITE,
            flags=select.KQ_EV_ADD | select.KQ_EV_ENABLE)
        self.events.append(w_event)
        self.event_to_object[f.fileno()] = f 
开发者ID:getsentry,项目名称:rb,代码行数:13,代码来源:poll.py

示例5: _is_closed_kqueue

# 需要导入模块: import select [as 别名]
# 或者: from select import KQ_EV_ENABLE [as 别名]
def _is_closed_kqueue(f):
    kqueue = select.kqueue()
    event = select.kevent(
        f.fileno(), filter=select.KQ_FILTER_READ,
        flags=select.KQ_EV_ADD | select.KQ_EV_ENABLE)
    for event in kqueue.control([event], 128, 0.0):
        if event.flags & select.KQ_EV_EOF:
            return True
    return False 
开发者ID:getsentry,项目名称:rb,代码行数:11,代码来源:poll.py

示例6: __add_ev_read

# 需要导入模块: import select [as 别名]
# 或者: from select import KQ_EV_ENABLE [as 别名]
def __add_ev_read(self, fileno):
        """
        Note:if the event exists,it will not do anything
        """
        if fileno not in self.__rlist and self.__async_mode == "select":
            self.__rlist.append(fileno)

        if self.__async_mode == "epoll":
            if fileno not in self.__epoll_register_info:
                self.__epoll_register_info[fileno] = None

            eventmask = self.__epoll_register_info[fileno]
            event = select.EPOLLIN

            if eventmask == None:
                eventmask = event

                self.__epoll_object.register(fileno, eventmask)
                self.__epoll_register_info[fileno] = eventmask

                return

            is_register_read = (eventmask & select.EPOLLIN) == select.EPOLLIN

            if is_register_read == False:
                eventmask = event | eventmask
                self.__epoll_object.modify(fileno, eventmask)

        if self.__async_mode == "kqueue":
            filter_ = select.KQ_FILTER_READ
            flags = select.KQ_EV_ADD | select.KQ_EV_ENABLE

            if fileno not in self.__kqueue_event_map:
                kevent = select.kevent(fileno, filter_, flags)
                kevent.udata = 0
            else:
                kevent = self.__kqueue_event_map[fileno]

            read_exists = (kevent.udata & EV_TYPE_READ) == EV_TYPE_READ

            if read_exists == False:
                kevent.filter = filter_
                kevent.udata = (kevent.udata | EV_TYPE_READ)
                kevent.flags = flags

                if fileno not in self.__kqueue_change_event_map:
                    self.__kqueue_change_event_map[fileno] = []

                self.__kqueue_change_event_map[fileno].append(kevent)
            ''''''

        return 
开发者ID:fdslight,项目名称:fdslight,代码行数:54,代码来源:event.py

示例7: __add_ev_write

# 需要导入模块: import select [as 别名]
# 或者: from select import KQ_EV_ENABLE [as 别名]
def __add_ev_write(self, fileno):
        if fileno not in self.__wlist and self.__async_mode == "select":
            self.__wlist.append(fileno)

        if self.__async_mode == "epoll":
            if fileno not in self.__epoll_register_info:
                self.__epoll_register_info[fileno] = None

            eventmask = self.__epoll_register_info[fileno]
            event = select.EPOLLOUT

            if eventmask == None:
                eventmask = event

                self.__epoll_object.register(fileno, eventmask)
                self.__epoll_register_info[fileno] = eventmask

                return

            is_register_write = (eventmask & select.EPOLLOUT) == select.EPOLLOUT

            if is_register_write == False:
                eventmask = event | eventmask
                self.__epoll_object.modify(fileno, eventmask)

        if self.__async_mode == "kqueue":
            filter_ = select.KQ_FILTER_WRITE
            flags = select.KQ_EV_ADD | select.KQ_EV_ENABLE

            if fileno not in self.__kqueue_event_map:
                kevent = select.kevent(fileno, filter_, flags)
                kevent.udata = 0
            else:
                kevent = self.__kqueue_event_map[fileno]

            write_exists = (kevent.udata & EV_TYPE_WRITE) == EV_TYPE_WRITE

            if write_exists == False:
                kevent.filter = filter_
                kevent.flags = flags
                kevent.udata = (kevent.udata | EV_TYPE_WRITE)

                if fileno not in self.__kqueue_change_event_map:
                    self.__kqueue_change_event_map[fileno] = []
                self.__kqueue_change_event_map[fileno].append(kevent)
            ''''''

        return 
开发者ID:fdslight,项目名称:fdslight,代码行数:50,代码来源:event.py


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