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


Python select.EPOLLERR屬性代碼示例

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


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

示例1: handle_fd_mask

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLERR [as 別名]
def handle_fd_mask(self, fd, mask):
        if fd == self._poll_bell.r:
            assert mask & select.EPOLLIN
            self._poll_bell.read(BELL_READ)  # flush the pipe
        else:
            # socket might have been already discarded by the Link
            # so this pass might be skipped
            if fd not in self._sock_by_fd:
                return
            sock = self._sock_by_fd[fd]

            if mask & (select.EPOLLERR | select.EPOLLHUP):
                self.handle_sock_err(sock)
            else:
                if sock in self._in_ssl_handshake:
                    if self.ssl_handshake(sock) == SSL_HANDSHAKE_DONE:
                        # connection is ready for user IO
                        self.on_connect(sock.conn_id)
                else:
                    self.handle_sock_io(fd, sock, mask)

    ########################################################## 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:24,代碼來源:link.py

示例2: register

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLERR [as 別名]
def register(self, sock, events, callback, *args, **kwargs):
        ev = select.EPOLLERR | select.EPOLLHUP
        need_modify = False
        if sock.fileno() in self.fd2socks:
            need_modify = True
        if events & EV_READ:
            ev |= select.EPOLLIN
        if events & EV_WRITE:
            ev |= select.EPOLLOUT
        if need_modify:
            self.epoll.modify(sock.fileno(), ev)
        else:
            try:
                self.epoll.register(sock.fileno(), ev)
            except (IOError, OSError):
                return False
            else:
                self.fd2socks[sock.fileno()] = sock
        return super(Epoll, self).register(sock, events, callback, *args, **kwargs) 
開發者ID:faicker,項目名稱:greendns,代碼行數:21,代碼來源:ioloop.py

示例3: bind

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLERR [as 別名]
def bind(self):
        """
        bind the ip:port
        """
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self._set_sock_params(sock)
        sock.bind((self._bind_ip, self._bind_port))
        self._set_sock_nonblocking(sock)
        log.info(
            'bind port info:(ip:%s, port:%s)' % (
                self._bind_ip, self._bind_port
            )
        )
        self._epoll.register(
            sock.fileno(),
            select.EPOLLIN | select.EPOLLET | select.EPOLLOUT | select.EPOLLERR
        )
        self._bind_sock = sock 
開發者ID:baidu,項目名稱:CUP,代碼行數:20,代碼來源:conn.py

示例4: _handle_new_conn

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLERR [as 別名]
def _handle_new_conn(self, newsock, peer):
        self._set_sock_params(newsock)
        self._set_sock_nonblocking(newsock)
        context = sockcontext.CConnContext()
        context.set_sock(newsock)
        context.set_conn_man(self)
        context.set_peerinfo(peer)
        self._epoll.register(
            newsock.fileno(), select.EPOLLIN | select.EPOLLET | select.EPOLLERR
        )
        self._rwlock.acquire_writelock()
        self._fileno2context[newsock.fileno()] = context
        self._peer2context[peer] = context
        self._context2fileno_peer[context] = (newsock.fileno(), peer)
        self._rwlock.release_writelock()
        log.info('a new connection: {0}'.format(peer)) 
開發者ID:baidu,項目名稱:CUP,代碼行數:18,代碼來源:conn.py

示例5: receiveMsg_Start_Websocket

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLERR [as 別名]
def receiveMsg_Start_Websocket(self, m, sender):
        if self.started: # already started
            return
        self.config = m
        self.started = True
        self.running = True

        # open the connection
        websocket.enableTrace(False)
        self.ws = websocket.create_connection(m.ws_addr)
        log.info("Websocket Connected")

        # set up the socket monitoring
        self.epoll = select.epoll()
        mask = select.EPOLLIN | select.EPOLLHUP | select.EPOLLERR
        self.epoll.register(self.ws.sock.fileno(), mask)

        # subscribe to the feed
        self.ws.send(m.start_msg)

        # start checking for data
        self.send(self.myAddress, WakeupMessage(None)) 
開發者ID:thespianpy,項目名稱:Thespian,代碼行數:24,代碼來源:websocket.py

示例6: __init__

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLERR [as 別名]
def __init__(self, pipe):
		if isinstance(pipe, int):
			fd = self._fd = pipe
			pipe = os.fromfd(pipe)
		else: fd = self._fd = pipe.fileno()
		self._poll_in, self._poll_out = epoll(), epoll()
		self._poll_in.register(fd, EPOLLIN | EPOLLERR | EPOLLHUP)
		self._poll_out.register(fd, EPOLLOUT | EPOLLERR | EPOLLHUP)
		self.close = pipe.close
		self.reads = pipe.read
		self.writes = pipe.write 
開發者ID:ActiveState,項目名稱:code,代碼行數:13,代碼來源:recipe-576759.py

示例7: doPoll

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLERR [as 別名]
def doPoll(self, block):
    readyList = self.__poller.poll(-1 if block else 0)
    for (fd, eventMask) in readyList:
      readReady = ((eventMask & select.EPOLLIN) != 0)
      writeReady = ((eventMask & select.EPOLLOUT) != 0)
      errorReady = ((eventMask & 
                     (select.EPOLLERR | select.EPOLLHUP)) != 0)
      self.handleEventForFD(fd = fd,
                            readReady = readReady,
                            writeReady = writeReady,
                            errorReady = errorReady) 
開發者ID:ActiveState,項目名稱:code,代碼行數:13,代碼來源:recipe-577662.py

示例8: register

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLERR [as 別名]
def register(self, fd, *masks):
            masks = [self.from_[x] for x in masks] + [
                select.EPOLLET, select.EPOLLERR, select.EPOLLHUP]
            self.q.register(fd, reduce(operator.or_, masks, 0)) 
開發者ID:cablehead,項目名稱:vanilla,代碼行數:6,代碼來源:poll.py

示例9: poll

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLERR [as 別名]
def poll(self, timeout=-1):
            events = self.q.poll(timeout=timeout)
            ret = []
            for fd, event in events:
                for mask in self.to_:
                    if event & mask:
                        ret.append((fd, self.to_[mask]))
                if event & (select.EPOLLERR | select.EPOLLHUP):
                    ret.append((fd, POLLERR))
            return ret 
開發者ID:cablehead,項目名稱:vanilla,代碼行數:12,代碼來源:poll.py

示例10: _run_command

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLERR [as 別名]
def _run_command(cmd, clear_streamed_output):
  """Calls the shell command, forwarding input received on the stdin_socket."""
  locale_encoding = locale.getpreferredencoding()
  if locale_encoding != _ENCODING:
    raise NotImplementedError(
        'A UTF-8 locale is required. Got {}'.format(locale_encoding))

  parent_pty, child_pty = pty.openpty()
  _configure_term_settings(child_pty)

  epoll = select.epoll()
  epoll.register(
      parent_pty,
      (select.EPOLLIN | select.EPOLLOUT | select.EPOLLHUP | select.EPOLLERR))

  try:
    temporary_clearer = _tags.temporary if clear_streamed_output else _no_op

    with temporary_clearer(), _display_stdin_widget(
        delay_millis=500) as update_stdin_widget:
      # TODO(b/115531839): Ensure that subprocesses are terminated upon
      # interrupt.
      p = subprocess.Popen(
          cmd,
          shell=True,
          executable='/bin/bash',
          stdout=child_pty,
          stdin=child_pty,
          stderr=child_pty,
          close_fds=True)
      # The child PTY is only needed by the spawned process.
      os.close(child_pty)

      return _monitor_process(parent_pty, epoll, p, cmd, update_stdin_widget)
  finally:
    epoll.close()
    os.close(parent_pty) 
開發者ID:googlecolab,項目名稱:colabtools,代碼行數:39,代碼來源:_system_commands.py

示例11: onIOEventFlagsChanged

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLERR [as 別名]
def onIOEventFlagsChanged(self, connect):
		if connect._ioEventFlags != sockConnect.socketIOEventFlagsNone:
			eventmask = select.EPOLLERR | select.EPOLLHUP
			if connect._ioEventFlags & sockConnect.socketIOEventFlagsRead:
				eventmask |= select.EPOLLIN
			if connect._ioEventFlags & sockConnect.socketIOEventFlagsWrite:
				eventmask |= select.EPOLLOUT
			if not connect.registerEpoll:
				self.epollor.register(connect._sock.fileno(), eventmask)
				connect.registerEpoll = True
			else:
				self.epollor.modify(connect._sock.fileno(), eventmask)
		else:
			self.epollor.unregister(connect._sock.fileno())
			connect.registerEpoll = False 
開發者ID:wdongxv,項目名稱:DDDProxy,代碼行數:17,代碼來源:baseServer.py

示例12: start

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLERR [as 別名]
def start(self):
		while True:
			eventList = self.epollor.poll(1, 1000)
			for fd, event in eventList:
				if select.EPOLLIN & event:
					self.onSocketEvent(fd, sockConnect.socketEventCanRecv)
				elif select.EPOLLOUT & event:
					self.onSocketEvent(fd, sockConnect.socketEventCanSend)
				elif select.EPOLLERR & event or select.EPOLLHUP & event:
					self.onSocketEvent(fd, sockConnect.socketEventExcept)
				else:
					log.log(3, "unknow event", event) 

			self._handlerCallback() 
開發者ID:wdongxv,項目名稱:DDDProxy,代碼行數:16,代碼來源:baseServer.py

示例13: poll

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLERR [as 別名]
def poll(self, timeout):
        """
        @param timeout: seconds
        """
        if len(self.fds) == 0:
            time.sleep(timeout)
            return []

        rlist = []
        wlist = []
        xlist = []
        for fd, mask in self.fds.items():
            fd = self._socket_to_fd(fd)
            if mask & select.EPOLLIN:
                rlist.append(fd)
            if mask & select.EPOLLOUT:
                wlist.append(fd)
            xlist.append(fd)

        rlist, wlist, xlist = select.select(rlist, wlist, xlist, timeout)

        res = {}
        for fd in rlist:
            res[fd] = res.get(fd, 0) | select.EPOLLIN
        for fd in wlist:
            res[fd] = res.get(fd, 0) | select.EPOLLOUT
        for fd in xlist:
            res[fd] = res.get(fd, 0) | select.EPOLLERR

        return res.items()

######################################################################### 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:34,代碼來源:poll.py

示例14: unregister

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLERR [as 別名]
def unregister(self, sock, events=EV_READ | EV_WRITE):
        if not super(Epoll, self).unregister(sock, events):
            return False
        ev = select.EPOLLERR | select.EPOLLHUP | \
            select.EPOLLIN | select.EPOLLOUT
        if events & EV_READ:
            ev ^= select.EPOLLIN
        if events & EV_WRITE:
            ev ^= select.EPOLLOUT
        self.epoll.modify(sock.fileno(), ev)
        return True 
開發者ID:faicker,項目名稱:greendns,代碼行數:13,代碼來源:ioloop.py

示例15: run

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLERR [as 別名]
def run(self):
        while self.running:
            self.check_timer()
            events = self.epoll.poll(self.MIN_INTERVAL)
            for fd, event in events:
                sock = self.fd2socks.get(fd)
                if not sock:
                    continue
                if event & select.EPOLLERR or event & select.EPOLLHUP:
                    if self.err_callback:
                        self.err_callback[0](sock, *self.err_callback[1],
                                             **self.err_callback[2])
                if event & select.EPOLLIN:
                    result = self.rd_socks.get(sock)
                    if not result:
                        continue
                    callback, args, kwargs = result
                    if callback:
                        callback(sock, *args, **kwargs)
                if event & select.EPOLLOUT:
                    result = self.wr_socks.get(sock)
                    if not result:
                        continue
                    callback, args, kwargs = result
                    if callback:
                        callback(sock, *args, **kwargs) 
開發者ID:faicker,項目名稱:greendns,代碼行數:28,代碼來源:ioloop.py


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