Hello,
I'm trying to build as a data consumer a python script with both
pika (RabbitMQ) and PyQtGraph
Unfortunately I get a frozen PyQtGraph window
My script contains this main function
def main(args):
#QtGui.QApplication.setGraphicsSystem('raster')
#mw = QtGui.QMainWindow()
#mw.resize(800,800)
pg.setConfigOption('background', 'w')
pg.setConfigOption('foreground', 'k')
win = pg.GraphicsWindow(title="Basic plotting examples")
win.resize(1000,600)
win.setWindowTitle('plot')
# Enable antialiasing for prettier plots
pg.setConfigOptions(antialias=True)
order_book_plot = OrderBookPlot(args, win)
import sys
## Start Qt event loop unless running in interactive mode or using pyside.
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
def main(args):
#QtGui.QApplication.setGraphicsSystem('raster')
app = QtGui.QApplication([])
#mw = QtGui.QMainWindow()
#mw.resize(800,800)
pg.setConfigOption('background', 'w')
pg.setConfigOption('foreground', 'k')
win = pg.GraphicsWindow(title="Basic plotting examples")
win.resize(1000,600)
win.setWindowTitle('plot')
# Enable antialiasing for prettier plots
pg.setConfigOptions(antialias=True)
order_book_plot = OrderBookPlot(args, win)
import sys
## Start Qt event loop unless running in interactive mode or using pyside.
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()
To copy to clipboard, switch view to plain text mode
and also this class
class ...:
....
def init_rabbitmq_connection(self):
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='localhost'))
channel = connection.channel()
exchange = 'topic_logs'
channel.exchange_declare(exchange=exchange,
type='topic')
result = channel.queue_declare(exclusive=True)
queue_name = result.method.queue
binding_keys = self.args.binding_keys.split(',')
for binding_key in binding_keys:
channel.queue_bind(exchange=exchange,
queue=queue_name,
routing_key=binding_key)
logging.info('[*] Waiting for data. To exit press CTRL+C')
channel.basic_consume(self.rabbitmq_data_callback,
queue=queue_name,
no_ack=True)
channel.start_consuming()
class ...:
....
def init_rabbitmq_connection(self):
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='localhost'))
channel = connection.channel()
exchange = 'topic_logs'
channel.exchange_declare(exchange=exchange,
type='topic')
result = channel.queue_declare(exclusive=True)
queue_name = result.method.queue
binding_keys = self.args.binding_keys.split(',')
for binding_key in binding_keys:
channel.queue_bind(exchange=exchange,
queue=queue_name,
routing_key=binding_key)
logging.info('[*] Waiting for data. To exit press CTRL+C')
channel.basic_consume(self.rabbitmq_data_callback,
queue=queue_name,
no_ack=True)
channel.start_consuming()
To copy to clipboard, switch view to plain text mode
Python Qt have an event loop
and I think it's doing odd things with pika.BlockingConnection
I don't know how to manage loop from pika and also loop from Qt.
Any help is welcome.
Femto
Bookmarks