def consume_danmaku(sock, danmaku_queue, is_health): """Consume danmakus. :param sock: the socket object. :param danmaku_queue: the queue to recieve danmaku. :param is_health: the status of connection """ while True: danmaku = get_danmaku(danmaku_queue) print danmaku produce_danmaku.switch(sock, danmaku_queue, is_health)
def consume_danmaku(sock, danmaku_queue, is_health): """Consume danmakus. :param sock: the socket object. :param danmaku_queue: the queue to recieve danmaku. :param is_health: the status of connection """ while True: danmaku = get_danmaku(danmaku_queue) try: print danmaku except TypeError: pass # 测试过这玩意返回 NoneType 的时候b站直播间也不行 produce_danmaku.switch(sock, danmaku_queue, is_health)