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


Python select.EPOLLHUP屬性代碼示例

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


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

示例1: run

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLHUP [as 別名]
def run(self):
		arcuslog(self, 'epoll start')

		while True:
			events = self.epoll.poll(2)

			if self.node_allocator.shutdown == True:
				arcuslog(self, 'epoll out')
				return

			for fileno, event in events:
				if event & select.EPOLLIN:
					node = self.sock_node_map[fileno]
					node.do_op()

				if event & select.EPOLLHUP:
					print('EPOLL HUP')
					epoll.unregister(fileno)
					node = self.sock_node_map[fileno]
					node.disconnect()
					del self.sock_node_map[fileno] 
開發者ID:naver,項目名稱:hubblemon,代碼行數:23,代碼來源:arcus_mc_node.py

示例2: handle_fd_mask

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

示例3: register

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

示例4: perform

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLHUP [as 別名]
def perform(self):
        ret = []
        for fd, event in self.epoll.poll():
            if event & select.EPOLLHUP:
                if DEBUG: DEBUG.info('downloader died')
                raise KeyboardInterrupt
            assert event & select.EPOLLIN
            done = self.running[fd].perform()
            if not done: continue
            assert len(done) == 1
            ret.extend(done)

            # dl finished, move it to the cache
            host = urlparse.urlsplit(done[0][0].url).netloc
            if host in self.cache: self.cache[host].abort()
            self.epoll.unregister(fd)
            self.cache[host] = self.running.pop(fd)
        return ret 
開發者ID:yandex,項目名稱:root-2015-tasks,代碼行數:20,代碼來源:grabber.py

示例5: receiveMsg_Start_Websocket

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

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLHUP [as 別名]
def run(self):
		arcuslog(self, 'epoll start')

		while True:
			events = self.epoll.poll(2)

			if self.node_allocator.shutdown == True:
				arcuslog(self, 'epoll out')
				return

			for fileno, event in events:
				if event & select.EPOLLIN:
					node = self.sock_node_map[fileno]
					node.do_op()

				if event & select.EPOLLHUP:
					print('EPOLL HUP')
					self.epoll.unregister(fileno)
					node = self.sock_node_map[fileno]
					node.disconnect()
					del self.sock_node_map[fileno] 
開發者ID:naver,項目名稱:arcus-python-client,代碼行數:23,代碼來源:arcus_mc_node.py

示例7: register

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLHUP [as 別名]
def register(self, key, f):
        BasePoller.register(self, key, f)
        self.epoll.register(f.fileno(), select.EPOLLIN | select.EPOLLHUP |
                            select.EPOLLOUT)
        self.fd_to_object[f.fileno()] = f 
開發者ID:getsentry,項目名稱:rb,代碼行數:7,代碼來源:poll.py

示例8: poll

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLHUP [as 別名]
def poll(self, timeout=None):
        if timeout is None:
            timeout = -1
        rv = []
        for fd, event in self.epoll.poll(timeout):
            obj = self.fd_to_object[fd]
            if event & select.EPOLLIN:
                rv.append((obj, 'read'))
            if event & select.EPOLLOUT:
                rv.append((obj, 'write'))
            if event & select.EPOLLHUP:
                rv.append((obj, 'close'))
        return rv 
開發者ID:getsentry,項目名稱:rb,代碼行數:15,代碼來源:poll.py

示例9: __init__

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

示例10: read

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLHUP [as 別名]
def read(self, bs=-1, to=-1, state=False): # read until timeout
		if to < 0: # use regular sync I/O
			buff = self.reads(bs)
			if state: return (buff, Size) if len(buff) == bs else (buff, End) # "Size" might mean "Size | End" here
			else: return buff
		try:
			flags = fcntl.fcntl(self._fd, fcntl.F_GETFL)
			fcntl.fcntl(self._fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
			deadline = time() + to
			buff = buffer('')
			while bs:
				try: fd, event = self._poll_in.poll(to, 1)[0] # get first event, fd should be eq self._fd
				except IndexError:
					if state: state = Time
					break
				if event != EPOLLHUP: # some data or error present
					ext = self.reads(min(bs, self.bs_max) if bs > 0 else self.bs_default) # min() for G+ reads
					buff += ext
				if event & EPOLLHUP: # socket is closed on the other end
					if state: state = End
					break
				to = deadline - time()
				if to < 0:
					if state: state = Time
					break
				bs -= len(ext)
			else: state = Size # got bs bytes
		finally:
			try: fcntl.fcntl(self._fd, fcntl.F_SETFL, flags) # restore blocking state
			except: pass # in case there was an error, caused by wrong fd/pipe (not to raise another one)
		return buff if not state else (buff, state) 
開發者ID:ActiveState,項目名稱:code,代碼行數:33,代碼來源:recipe-576759.py

示例11: write

# 需要導入模塊: import select [as 別名]
# 或者: from select import EPOLLHUP [as 別名]
def write(self, buff, to=-1, state=False): # mostly similar (in reverse) to read
		if to < 0:
			bs = self.writes(buff)
			if state: return (bs, Size) if len(buff) == bs else (bs, End) # "Size" might mean "Size | End" here
			else: return bs
		try:
			flags = fcntl.fcntl(self._fd, fcntl.F_GETFL)
			fcntl.fcntl(self._fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
			bs = 0
			deadline = time() + to
			while buff:
				try: fd, event = self._poll_out.poll(to, 1)[0]
				except IndexError:
					if state: state = Time
					break
				if event != EPOLLHUP:
					ext = os.write(fd, buff)
					bs += ext
				if event & EPOLLHUP:
					if state: state = End
					break
				to = deadline - time()
				if to < 0:
					if state: state = Time
					break
				buff = buffer(buff, ext)
		finally:
			try: fcntl.fcntl(self._fd, fcntl.F_SETFL, flags)
			except: pass
		return bs if not state else (bs, state) 
開發者ID:ActiveState,項目名稱:code,代碼行數:32,代碼來源:recipe-576759.py

示例12: doPoll

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

示例13: register

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

示例14: poll

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

示例15: _run_command

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


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