當前位置: 首頁>>代碼示例>>Python>>正文


Python select.KQ_EV_EOF屬性代碼示例

本文整理匯總了Python中select.KQ_EV_EOF屬性的典型用法代碼示例。如果您正苦於以下問題:Python select.KQ_EV_EOF屬性的具體用法?Python select.KQ_EV_EOF怎麽用?Python select.KQ_EV_EOF使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在select的用法示例。


在下文中一共展示了select.KQ_EV_EOF屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: poll

# 需要導入模塊: import select [as 別名]
# 或者: from select import KQ_EV_EOF [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: poll

# 需要導入模塊: import select [as 別名]
# 或者: from select import KQ_EV_EOF [as 別名]
def poll(self, timeout=None):
        events = self.kqueue.control(self.events, 128, timeout)
        rv = []
        for ev in events:
            obj = self.event_to_object.get(ev.ident)
            if obj is None:
                # It happens surprisingly frequently that kqueue returns
                # write events things no longer in the kqueue.  Not sure
                # why
                continue
            if ev.filter == select.KQ_FILTER_READ:
                rv.append((obj, 'read'))
            elif ev.filter == select.KQ_FILTER_WRITE:
                rv.append((obj, 'write'))
            if ev.flags & select.KQ_EV_EOF:
                rv.append((obj, 'close'))
        return rv 
開發者ID:getsentry,項目名稱:rb,代碼行數:19,代碼來源:poll.py

示例3: _is_closed_kqueue

# 需要導入模塊: import select [as 別名]
# 或者: from select import KQ_EV_EOF [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

示例4: poll

# 需要導入模塊: import select [as 別名]
# 或者: from select import KQ_EV_EOF [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

示例5: _doWriteOrRead

# 需要導入模塊: import select [as 別名]
# 或者: from select import KQ_EV_EOF [as 別名]
def _doWriteOrRead(self, selectable, fd, event):
        """
        Private method called when a FD is ready for reading, writing or was
        lost. Do the work and raise errors where necessary.
        """
        why = None
        inRead = False
        (filter, flags, data, fflags) = (
            event.filter, event.flags, event.data, event.fflags)

        if flags & KQ_EV_EOF and data and fflags:
            why = main.CONNECTION_LOST
        else:
            try:
                if selectable.fileno() == -1:
                    inRead = False
                    why = posixbase._NO_FILEDESC
                else:
                    if filter == KQ_FILTER_READ:
                        inRead = True
                        why = selectable.doRead()
                    if filter == KQ_FILTER_WRITE:
                        inRead = False
                        why = selectable.doWrite()
            except:
                # Any exception from application code gets logged and will
                # cause us to disconnect the selectable.
                why = failure.Failure()
                log.err(why, "An exception was raised from application code" \
                             " while processing a reactor selectable")

        if why:
            self._disconnectSelectable(selectable, why, inRead) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:35,代碼來源:kqreactor.py

示例6: doPoll

# 需要導入模塊: import select [as 別名]
# 或者: from select import KQ_EV_EOF [as 別名]
def doPoll(self, block):
    eventList = self.__kqueue.control(
                  None,
                  self.getNumFDs() * 2,
                  None if block else 0)
    for ke in eventList:
      fd = ke.ident
      readReady = (ke.filter == select.KQ_FILTER_READ)
      writeReady = (ke.filter == select.KQ_FILTER_WRITE)
      errorReady = ((ke.flags & select.KQ_EV_EOF) != 0)
      self.handleEventForFD(fd = fd,
                            readReady = readReady,
                            writeReady = writeReady,
                            errorReady = errorReady) 
開發者ID:ActiveState,項目名稱:code,代碼行數:16,代碼來源:recipe-577662.py

示例7: start

# 需要導入模塊: import select [as 別名]
# 或者: from select import KQ_EV_EOF [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

示例8: poll

# 需要導入模塊: import select [as 別名]
# 或者: from select import KQ_EV_EOF [as 別名]
def poll(self, timeout):
        for event in self._kq.control(None, 100, timeout):
            yield ProcPollEvent(fd=event.ident,
                                can_read=True,
                                is_terminated=event.flags & select.KQ_EV_EOF) 
開發者ID:Netflix,項目名稱:metaflow,代碼行數:7,代碼來源:procpoll.py


注:本文中的select.KQ_EV_EOF屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。