# -*- coding: utf-8 -*-
import time
from multiprocessing import Queue

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

def clear_queue(queue, is_close=False):
    while True:
        if queue.empty() or queue.qsize() == 0:
            if is_close:
                queue.close()
            break
        r = get_no_block_queue(queue)
        del r

aa = Queue(10)
aa.put("111")
aa.put("111")
aa.cancel_join_thread()
time.sleep(2)
clear_queue(aa, is_close=True)
clear_queue(aa, is_close=True)
print("111111")