Пример #1
0
    total_count = 0
    total_cost = 0
    message = "PAUSE"  # default start

    while 1:
        event = poller.poll(1)
        if event:
            socks = dict(poller.poll(1))
        else:
            socks = None

        if socks and socks.get(
                controller) == zmq.POLLIN:  # receive data from zmq pollor
            item = controller.recv()
            if item == "PAUSE":  # pause the vent work
                message = "PAUSE"
                time.sleep(10)
                continue
            elif item == "RESTART":  # restart the vent work
                message = "RESTART"
                total_count, total_cost = send_weibo(sender, total_count,
                                                     total_cost)
        else:
            if message == "PAUSE":
                time.sleep(10)
                print message
                continue
            else:
                total_count, total_cost = send_weibo(sender, total_count,
                                                     total_cost)
    while 1:
        event = poller.poll(1)
        if event:
            socks = dict(poller.poll(1))
        else:
            socks = None

        if socks and socks.get(
                controller) == zmq.POLLIN:  # receive data from zmq pollor
            item = controller.recv()
            if item == "PAUSE":  # pause the vent work
                message = "PAUSE"
                time.sleep(1)
                continue
            elif item == "RESTART":  # restart the vent work
                message = "RESTART"
                total_count, total_cost = send_weibo(sender, poller,
                                                     controller, total_count,
                                                     total_cost)
        else:
            if message == "PAUSE":
                time.sleep(1)
                print message
                continue
            else:
                time.sleep(1)
                total_count, total_cost = send_weibo(sender, poller,
                                                     controller, total_count,
                                                     total_cost)
    message = "RESTART" # default start

    while 1:
        event = poller.poll(0)
        if event:
            socks = dict(poller.poll(0))
        else:
            socks = None

        if socks and socks.get(controller) == zmq.POLLIN: # receive data from zmq pollor
            item = controller.recv()
            if item == "PAUSE": # pause the vent work
                message = "PAUSE"
                time.sleep(1)
                continue
            elif item == "RESTART": # restart the vent work
                message = "RESTART"
                total_count, total_cost = send_weibo(sender, total_count, total_cost)
        else:
            if message == "PAUSE":
                time.sleep(1)
                print message
                continue
            else:
                time.sleep(1)
                total_count, total_cost = send_weibo(sender, total_count, total_cost)




    while 1:
        event = poller.poll(0)
        if event:
            socks = dict(poller.poll(0))
        else:
            socks = None

        if socks and socks.get(controller) == zmq.POLLIN: # receive data from zmq pollor
            item = controller.recv()
            if item == "PAUSE": # pause the vent work
                message = "PAUSE"
                time.sleep(1)
                continue
            elif item == "RESTART": # restart the vent work
                message = "RESTART"
                total_count, total_cost = send_weibo(sender, poller, controller, total_count, total_cost)
        else:
            if message == "PAUSE":
                time.sleep(1)
                print message
                continue
            else:
                time.sleep(1)
                total_count, total_cost = send_weibo(sender, poller, controller, total_count, total_cost)