當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。