flask-pika
flask-pika copied to clipboard
Unable to run the publisher and flask app simultaneously
Hello,
I am trying to use your library to be able to run multiple pika subscribers/publishers in a flask app. I think I am not using the library right because once I run my code, I am not able to see the flask app started message on my console. Below is the code I wrote using your guidelines :
from flask import Flask
from flask_pika import Pika as FPika
app = Flask(__name__)
app.config['FLASK_PIKA_PARAMS'] = {
'host':'localhost', #amqp.server.com
'port': 5672, #amqp server port
'username' : 'guest',
'password' : 'guest',
'virtual_host':'vhost' #amqp vhost
}
app.config['FLASK_PIKA_POOL_PARAMS'] = {
'pool_size': 8,
'pool_recycle': 600
}
fpika = FPika(app)
ch = fpika.channel()
ch.basic_publish(exchange='daemon',routing_key='routing_key',exchange_type = 'fanout')
fpika.return_channel(ch)
if __name__ == "__main__":
app.run()
Could you please review this and tell me if this looks good or what is the problem here?
Hi, @sourabhsriom did you find a solution for this? Do you happen to have an implementation of the consumer in flask as well?