from queue import Queue as Pipe
from threading import Thread


class Filter2(Thread):
    q_in: Pipe
    q_out: Pipe

    def run(self):
        while True:
            msg = self.q_in.get()
            if isinstance(msg, EOFError):
                break
            msg2 = self.q_in.get()
            if isinstance(msg2, EOFError):
                break
            self.q_out.put((msg, msg2))
        self.q_out.put(EOFError(""))
