<commit_before>#!/usr/bin/env python
import pika
import sys
import os

broker_host = os.environ.get("broker_host")
broker_exchange = os.environ.get("broker_exchange")

connection = pika.BlockingConnection(pika.ConnectionParameters(host=broker_host))
channel = connection.channel()

channel.exchange_declare(exchange=broker_exchange)

result = channel.queue_declare(exclusive=True)

def callback(ch, method, properties, body):
    print(" [x] Received %r" % body)

channel.basic_consume(callback,queue=.#,no_ack=True)

print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()
<commit_msg>fixed pika listener<commit_after>#!/usr/bin/env python
import pika
import sys
import os

# tested with
# export broker_host=127.0.0.1
# export broker_exchange=son-kernel

broker_host = os.environ.get("broker_host")
broker_exchange = os.environ.get("broker_exchange")

connection = pika.BlockingConnection(pika.ConnectionParameters(host=broker_host))
channel = connection.channel()

channel.exchange_declare(exchange=broker_exchange,
                         type='topic')

result = channel.queue_declare(exclusive=True)
queue_name = result.method.queue

# lets listen to all topics: binding_key="#"
channel.queue_bind(exchange=broker_exchange,
                   queue=queue_name,
                   routing_key="#")


def callback(ch, method, properties, body):
    print(" [x] Received %r" % body)

channel.basic_consume(callback, queue=queue_name, no_ack=True)

print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()

{'fraction_non_alphanumeric': 0.11979500320307496, 'fraction_numerical': 0.003843689942344651, 'mean_word_length': 5.349593495934959, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '487267', 'n_tokens_mistral': 523, 'n_tokens_neox': 493, 'n_words': 100}