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

Qt Code:
  1. def main(args):
  2. #QtGui.QApplication.setGraphicsSystem('raster')
  3. app = QtGui.QApplication([])
  4. #mw = QtGui.QMainWindow()
  5. #mw.resize(800,800)
  6.  
  7. pg.setConfigOption('background', 'w')
  8. pg.setConfigOption('foreground', 'k')
  9.  
  10. win = pg.GraphicsWindow(title="Basic plotting examples")
  11. win.resize(1000,600)
  12. win.setWindowTitle('plot')
  13.  
  14. # Enable antialiasing for prettier plots
  15. pg.setConfigOptions(antialias=True)
  16.  
  17. order_book_plot = OrderBookPlot(args, win)
  18.  
  19. import sys
  20. ## Start Qt event loop unless running in interactive mode or using pyside.
  21. if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
  22. QtGui.QApplication.instance().exec_()
To copy to clipboard, switch view to plain text mode 

and also this class

Qt Code:
  1. class ...:
  2. ....
  3. def init_rabbitmq_connection(self):
  4. connection = pika.BlockingConnection(pika.ConnectionParameters(
  5. host='localhost'))
  6. channel = connection.channel()
  7.  
  8. exchange = 'topic_logs'
  9.  
  10. channel.exchange_declare(exchange=exchange,
  11. type='topic')
  12.  
  13. result = channel.queue_declare(exclusive=True)
  14. queue_name = result.method.queue
  15.  
  16. binding_keys = self.args.binding_keys.split(',')
  17.  
  18. for binding_key in binding_keys:
  19. channel.queue_bind(exchange=exchange,
  20. queue=queue_name,
  21. routing_key=binding_key)
  22.  
  23. logging.info('[*] Waiting for data. To exit press CTRL+C')
  24.  
  25.  
  26. channel.basic_consume(self.rabbitmq_data_callback,
  27. queue=queue_name,
  28. no_ack=True)
  29.  
  30. 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