import time
from multiprocessing import Process, Queue


def get_no_block_queue(queue):
    try:
        return queue.get(block=False)
    except Exception:
        return None


class B(Process):
    def __init__(self, a, b, c, d):
        super().__init__()
        self.a = a
        self.b = b
        self.c = c
        self.d = d

    def run(self):
        self.a.put("11111111111")
        self.b.put("11111111111")
        self.c.put("11111111111")
        self.d.put("11111111111")
        time.sleep(3)

class D(Process):
    def __init__(self, a, b, c, d):
        super().__init__()
        self.a = a
        self.b = b
        self.c = c
        self.d = d

    def run(self):
        self.a.put("11111111111")
        self.b.put("11111111111")
        self.c.put("11111111111")
        self.d.put("11111111111")
        time.sleep(3)


class C(Process):
    def __init__(self, a, b, c, d):
        super().__init__()
        self.a = a
        self.b = b
        self.c = c
        self.d = d

    def run(self):
        self.a.put("[encoded data, 7144 characters]")
        self.b.put("[encoded data, 7144 characters]")
        self.c.put("[encoded data, 7144 characters]")
        self.d.put("[encoded data, 714400 characters]")
        self.d.cancel_join_thread()
        time.sleep(3)


class A(Process):
    def __init__(self):
        super().__init__()
        self.a = Queue()
        self.b = Queue()
        self.c = Queue()
        self.d = Queue()

    def run(self):
        b = B(self.a, self.b, self.c, self.d)
        b.daemon = True
        b.start()
        c = C(self.a, self.b, self.c, self.d)
        c.daemon = True
        c.start()
        d = D(self.a, self.b, self.c, self.d)
        d.daemon = True
        d.start()
        while True:
            time.sleep(1)
            print("11111111111111")
            #b.join()
            print("222222222222222222")
            #c.join()
            print("333333333333333333")


if __name__ == "__main__":
    aa = A()
    aa.start()
