title: Make epoll return an fd once, without writing
body: <p>I have a master and a worker thread. The master thread accepts incoming connections and reads once from them. He then calls epoll.register(sock). The worker does epoll.poll() and does further reading and processing of incoming data.</p>
  
  <p>The thing is: If there incoming data is very short, no more data coming from the fd after the first read which is done in the master thread, the worker thread is forever blocking in epoll.poll(). What he should do is, he should at least once wake up and return the newly added file descriptor.</p>
  
  <p>How can I do this.</p>
  
  <p>My current approach:</p>
  
  <p>Master:</p>
  
  <pre><code>worker.epoll.register(sock.fileno())
  worker.forced_fds_to_handle.add(sock.fileno())
  </code></pre>
  
  <p>Worker:</p>
  
  <pre><code>while True:
    for fileno, event in self.epoll.poll(1):
      self.forced_fds_to_handle.discard(fileno)
      self._process(fileno, event)
  
    while self.forced_fds_to_handle:
      fileno = self.forced_fds_to_handle.pop()
      self._process(fileno, select.EPOLLIN)
  </code></pre>
  
  <p>What I don't like about this approach: In the worst case the worker ignores the incoming fd for a second which means delay for my clients. Of course I could make the timeout smaller but then it would  somehow waste resources.</p>
  
  <p>I'd really appreciate if somebody knew something better.</p>
  
  <p>I already tried:</p>
  
  <p>In the master:</p>
  
  <pre><code>sock.write('')
  </code></pre>
  
  <p>... to trigger an EPOLLIN, but that didn't work.</p>