Python Forum
pika channel.start_consuming() is not running - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: pika channel.start_consuming() is not running (/thread-16914.html)



pika channel.start_consuming() is not running - sundar - Mar-20-2019

Hi,
I am using python3.5.3 and pika version 0.13.0
My code
def functions(host):
    global LOGGER
    global RABBITMQ_USER
    global RABBITMQ_PASSWORD
    while True:
        try:
            credentials = pika.PlainCredentials(RABBITMQ_USER, RABBITMQ_PASSWORD)
            connection = pika.BlockingConnection(pika.ConnectionParameters(
                    host=host,
                    credentials=credentials))
            print(connection)
            channel = connection.channel()
            channel.basic_qos(prefetch_size=0, prefetch_count=0, all_channels=True)
            channel.basic_consume(basic_handler,
                              queue='grinshares',
                              no_ack=False)
            channel.basic_consume(basic_handler,
                              queue='poolshares',
                              no_ack=False)
            print("1")
            channel.start_consuming()
            print("2")
        except Exception as e:
            LOGGER.error("Something went wrong: {}\n{}".format(e, traceback.format_exc().splitlines()))
            sys.stdout.flush()
            time.sleep(10)
basic_handler definition
def basic_handler(ch, method, properties, body):
    global LOGGER
    global SHARES
    global HEIGHT
    print("I am reached here")
    /// some code
    sys.stdout.flush()
While i run i am getting . I mention some print statements in my code

<BlockingConnection impl=<SelectConnection OPEN socket=('127.0.0.1', 40068)->('127.0.0.1', 5672) params=<ConnectionParameters host=
localhost port=5672 virtual_host=/ ssl=False>>>
1


It did't call basic_handler definition . I am not getting the message "I am reached here" in baic_handler definition

I cannot understand what i did wrong why it is not calling the function basic_handler