Python select.EPOLLHUP Examples

The following are 28 code examples of select.EPOLLHUP(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module select , or try the search function .
Example #1
Source File: arcus_mc_node.py    From arcus-python-client with Apache License 2.0 6 votes vote down vote up
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] 
Example #2
Source File: grabber.py    From root-2015-tasks with GNU General Public License v3.0 6 votes vote down vote up
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 
Example #3
Source File: arcus_mc_node.py    From hubblemon with Apache License 2.0 6 votes vote down vote up
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] 
Example #4
Source File: ioloop.py    From greendns with MIT License 6 votes vote down vote up
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) 
Example #5
Source File: link.py    From luscan-devel with GNU General Public License v2.0 6 votes vote down vote up
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)

    ########################################################## 
Example #6
Source File: baseServer.py    From DDDProxy with Apache License 2.0 5 votes vote down vote up
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() 
Example #7
Source File: arcus_mc_node.py    From arcus-python-client with Apache License 2.0 5 votes vote down vote up
def register_node(self, node):
		self.epoll.register(node.get_fileno(), select.EPOLLIN | select.EPOLLHUP)

		arcuslog(self, 'regist node: ', node.get_fileno(), node)
		self.sock_node_map[node.get_fileno()] = node 
Example #8
Source File: websocket.py    From Thespian with MIT License 5 votes vote down vote up
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)) 
Example #9
Source File: launch.py    From pysipp with GNU General Public License v2.0 5 votes vote down vote up
def __call__(self, cmds, block=True, rate=300, **kwargs):
        if self._waiter and self._waiter.is_alive():
            raise RuntimeError(
                "Not all processes from a prior run have completed"
            )
        if self._procs:
            raise RuntimeError(
                "Process results have not been cleared from previous run"
            )
        sp = self.spm
        os = self.osm
        DEVNULL = open(os.devnull, 'wb')
        fds2procs = OrderedDict()

        # run agent commands in sequence
        for cmd in cmds:
            log.debug(
                "launching cmd:\n\"{}\"\n".format(cmd))
            proc = sp.Popen(
                shlex.split(cmd),
                stdout=DEVNULL,
                stderr=sp.PIPE
            )
            fd = proc.stderr.fileno()
            log.debug("registering fd '{}' for pid '{}'".format(
                fd, proc.pid))
            fds2procs[fd] = self._procs[cmd] = proc
            # register for stderr hangup events
            self.poller.register(proc.stderr.fileno(), select.EPOLLHUP)
            # limit launch rate
            time.sleep(1. / rate)

        # launch waiter
        self._waiter = threading.Thread(target=self._wait, args=(fds2procs,))
        self._waiter.daemon = True
        self._waiter.start()

        return self.get(**kwargs) if block else self._procs 
Example #10
Source File: 12_4_simple_web_server_with_epoll.py    From Python-Network-Programming with MIT License 5 votes vote down vote up
def run(self):
        """Executes epoll server operation"""
        try:
            connections = {}; requests = {}; responses = {}
            while True:
                events = self.epoll.poll(1)
                for fileno, event in events:
                    if fileno == self.sock.fileno():
                        connection, address = self.sock.accept()
                        connection.setblocking(0)
                        self.epoll.register(connection.fileno(), select.EPOLLIN)
                        connections[connection.fileno()] = connection
                        requests[connection.fileno()] = b''
                        responses[connection.fileno()] = SERVER_RESPONSE
                    elif event & select.EPOLLIN:
                        requests[fileno] += connections[fileno].recv(1024)
                        if EOL1 in requests[fileno] or EOL2 in requests[fileno]:
                            self.epoll.modify(fileno, select.EPOLLOUT)
                            print('-'*40 + '\n' + requests[fileno].decode()[:-2])
                    elif event & select.EPOLLOUT:
                        byteswritten = connections[fileno].send(responses[fileno])
                        responses[fileno] = responses[fileno][byteswritten:]
                        if len(responses[fileno]) == 0:
                            self.epoll.modify(fileno, 0)
                            connections[fileno].shutdown(socket.SHUT_RDWR)
                    elif event & select.EPOLLHUP:
                        self.epoll.unregister(fileno)
                        connections[fileno].close()
                        del connections[fileno]
        finally:
            self.epoll.unregister(self.sock.fileno())
            self.epoll.close()
            self.sock.close() 
Example #11
Source File: 2_4_simple_web_server_with_epoll.py    From Python-Network-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def run(self):
        """Executes epoll server operation"""
        try:
            connections = {}; requests = {}; responses = {}
            while True:
                events = self.epoll.poll(1)
                for fileno, event in events:
                    if fileno == self.sock.fileno():
                        connection, address = self.sock.accept()
                        connection.setblocking(0)
                        self.epoll.register(connection.fileno(), select.EPOLLIN)
                        connections[connection.fileno()] = connection
                        requests[connection.fileno()] = b''
                        responses[connection.fileno()] = SERVER_RESPONSE
                    elif event & select.EPOLLIN:
                        requests[fileno] += connections[fileno].recv(1024)
                        if EOL1 in requests[fileno] or EOL2 in requests[fileno]:
                            self.epoll.modify(fileno, select.EPOLLOUT)
                            print('-'*40 + '\n' + requests[fileno].decode()[:-2])
                    elif event & select.EPOLLOUT:
                        byteswritten = connections[fileno].send(responses[fileno])
                        responses[fileno] = responses[fileno][byteswritten:]
                        if len(responses[fileno]) == 0:
                            self.epoll.modify(fileno, 0)
                            connections[fileno].shutdown(socket.SHUT_RDWR)
                    elif event & select.EPOLLHUP:
                        self.epoll.unregister(fileno)
                        connections[fileno].close()
                        del connections[fileno]
        finally:
            self.epoll.unregister(self.sock.fileno())
            self.epoll.close()
            self.sock.close() 
Example #12
Source File: gdbstub.py    From pyvmidbg with GNU General Public License v3.0 5 votes vote down vote up
def read_packet(self):
        epoll = select.epoll()
        epoll.register(self.sock.fileno(),  select.EPOLLIN | select.EPOLLHUP | select.EPOLLRDHUP)
        while self.attached:
            events = epoll.poll()
            for fileno, event in events:
                if fileno == self.sock.fileno():
                    if event == select.EPOLLIN:
                        self.buffer += self.sock.recv(PACKET_SIZE)
                    if event == select.EPOLLHUP:
                        self.log.debug('EPOLLHUP')
                    if event == select.EPOLLRDHUP:
                        self.log.debug('EPOLLRDHUP')
                else:
                    raise RuntimeError('unknown fd %d', fileno)
            # CTRL-C ?
            m = re.match(b'\x03', self.buffer)
            if m:
                self.buffer = self.buffer[1:]
                # create a normal packet to let stub call a handler
                return b'\x03'
            # packet ?
            m = re.match(b'\\$(?P<data>.*?)#(?P<checksum>..)', self.buffer)
            if m:
                packet_data = m.group('data')
                packet_checksum = int(m.group('checksum'), 16)
                if not self.no_ack:
                    self.validate_packet(packet_data, packet_checksum)
                self.buffer = self.buffer[m.endpos+1:]
                return packet_data
            # not enough packet data to match a packet regex 
Example #13
Source File: ioloop.py    From greendns with MIT License 5 votes vote down vote up
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) 
Example #14
Source File: ioloop.py    From greendns with MIT License 5 votes vote down vote up
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 
Example #15
Source File: poll.py    From rb with Apache License 2.0 5 votes vote down vote up
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 
Example #16
Source File: baseServer.py    From DDDProxy with Apache License 2.0 5 votes vote down vote up
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 
Example #17
Source File: arcus_mc_node.py    From hubblemon with Apache License 2.0 5 votes vote down vote up
def register_node(self, node):
		self.epoll.register(node.get_fileno(), select.EPOLLIN | select.EPOLLHUP)

		arcuslog(self, 'regist node: ', node.get_fileno(), node)
		self.sock_node_map[node.get_fileno()] = node 
Example #18
Source File: _system_commands.py    From colabtools with Apache License 2.0 5 votes vote down vote up
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) 
Example #19
Source File: poll.py    From vanilla with MIT License 5 votes vote down vote up
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 
Example #20
Source File: poll.py    From vanilla with MIT License 5 votes vote down vote up
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)) 
Example #21
Source File: recipe-577662.py    From code with MIT License 5 votes vote down vote up
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) 
Example #22
Source File: recipe-576759.py    From code with MIT License 5 votes vote down vote up
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) 
Example #23
Source File: recipe-576759.py    From code with MIT License 5 votes vote down vote up
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) 
Example #24
Source File: recipe-576759.py    From code with MIT License 5 votes vote down vote up
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 
Example #25
Source File: poll.py    From rb with Apache License 2.0 5 votes vote down vote up
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 
Example #26
Source File: conn.py    From CUP with Apache License 2.0 4 votes vote down vote up
def poll(self):
        """
        start to poll
        """
        self._thdpool.start()
        self._executor.run()
        log.info('thdpool and executor start')
        misc.check_not_none(self._bind_sock)
        self._bind_sock.listen(10)
        self._executor.delay_exec(
            2,   # todo set the check_time to ?
            self.do_check_msg_ack_loop,
            urgency=executor.URGENCY_HIGH
        )
        while not self._stopsign:
            try:
                events = self._epoll.poll(1)
            except IOError as err:
                if err.errno == errno.EINTR:
                    return
                raise err
            # log.debug('start to poll')
            for fileno, event in events:
                # if it comes from the listen port, new conn
                if fileno == self._bind_sock.fileno():
                    newsock, addr = self._bind_sock.accept()
                    self._handle_new_conn(newsock, addr)
                elif event & select.EPOLLIN:
                    try:
                        self._handle_new_recv(self._fileno2context[fileno])
                    except KeyError:
                        log.info('socket already closed')
                elif event & select.EPOLLOUT:
                    try:
                        self._handle_new_send(self._fileno2context[fileno])
                    except KeyError:
                        log.info('socket already closed')
                elif (event & select.EPOLLHUP) or (event & select.EPOLLERR):
                    # FIXME: consider if we need to release net msg resources
                    if event & select.EPOLLHUP:
                        log.info('--EPOLLHUP--')
                    else:
                        log.info('--EPOLLERR--')
                    try:
                        self.cleanup_error_context(
                            self._fileno2context[fileno]
                        )
                    except KeyError:
                        log.info('socket already closed') 
Example #27
Source File: asyncio.py    From pycopia with Apache License 2.0 4 votes vote down vote up
def poll(self, timeout=-1.0):
        while 1:
            try:
                rl = self.pollster.poll(timeout)
            except IOError as why:
                if why.errno == EINTR:
                    self._run_idle()
                    continue
                else:
                    raise
            else:
                break
        for fd, flags in rl:
            try:
                hobj = self.smap[fd]
            except KeyError: # this should never happen, but let's be safe.
                continue
            if hobj is None: # signals simple callback
                self._fd_callbacks[fd]()
                continue
            try:
                if (flags & EPOLLERR):
                    hobj.error_handler()
                    continue
                if (flags & POLLNVAL):
                    self.unregister_fd(fd)
                    continue
                if (flags & EPOLLPRI):
                    hobj.pri_handler()
                if (flags & EPOLLIN):
                    hobj.read_handler()
                if (flags & EPOLLOUT):
                    hobj.write_handler()
                if (flags & EPOLLHUP):
                    hobj.hangup_handler()
            except UnregisterNow as unr:
                self.unregister(unr.obj)
            except UnregisterFDNow as unr:
                self.unregister_fd(unr.filedescriptor)
            except (KeyboardInterrupt, SystemExit):
                raise
            except:
                ex, val, tb = sys.exc_info()
                hobj.exception_handler(ex, val, tb) 
Example #28
Source File: polling.py    From vlcp with Apache License 2.0 4 votes vote down vote up
def pollEvents(self, wait):
            ret = []
            epwrite = select.EPOLLOUT|select.EPOLLWRNORM|select.EPOLLWRBAND
            epread = select.EPOLLIN|select.EPOLLRDNORM|select.EPOLLRDBAND|select.EPOLLPRI
            eperr = select.EPOLLERR
            ephup = select.EPOLLHUP
            if self.socketCounter <= 0 and wait is None:
                return ([], True)
            generateFree = False
            if wait is None or (self.maxwait is not None and wait > self.maxwait):
                generateFree = True
                wait = self.maxwait
            events = []
            try:
                interrupted = False
                self.shouldraise = True
                if wait is None:
                    events = self.epoll.poll()
                else:
                    events = self.epoll.poll(wait)
                self.shouldraise = False
            except InterruptedBySignalException:
                interrupted = True
            except IOError as exc:
                if exc.args[0] == errno.EINTR:
                    interrupted = True
                else:
                    raise
            finally:
                self.shouldraise = False                
            for fd, e in events:
                if e & epwrite:
                    ret.append(PollEvent(fd, PollEvent.WRITE_READY, e & epwrite))
                if e & epread:
                    ret.append(PollEvent(fd, PollEvent.READ_READY, e & epread))
                if e & eperr:
                    ret.append(PollEvent(fd, PollEvent.ERROR, e & eperr))
                if e & ephup:
                    ret.append(PollEvent(fd, PollEvent.HANGUP, e & ephup))
            if not ret and generateFree and not interrupted:
                ret.append(SystemControlLowPriorityEvent(SystemControlLowPriorityEvent.FREE))
            return (ret, False)