[rabbitmq-discuss] Using Pika and PyQtGraph (Qt event loop and BlockingConnection)
Femto
femto.trader at gmail.com
Sun May 11 17:57:51 BST 2014
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')
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_()
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()
maybe you noticed Qt have an event loop
and I think it's doing odd things with pika.BlockingConnection
Any help is welcome.
Femto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140511/838a70d1/attachment.html>
More information about the rabbitmq-discuss
mailing list