def in_thread():
                while True:
                    event = self._completion_queue.poll()
                    with self._condition:
                        self._events[event.tag].append(event)
                        self._due[event.tag] -= 1
                        self._condition.notify_all()
                        if self._due[event.tag] <= 0:
                            self._due.pop(event.tag)
                            if not self._due:
                                return