You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Fredrik Hallenberg <me...@gmail.com> on 2021/06/28 14:30:59 UTC
Python tornado and qpid
Hi, I am trying to get the Python tornado container working with qpid
proton 0.34. My goal is to create a tornado server that can also send and
receive amqp messages using a timer tick. With the below example tornado
server works fine but I am not able to run both ticks and amqp connection.
If the schedule call below is uncommented the amqp connection stops
working. I can also comment out create_sender/receive and then timer ticks
works.
It seems to me that something is missing in the tornado container, or am I
doing something wrong?
Thanks
from proton import Message
from proton.handlers import MessagingHandler
from proton_tornado import Container
import tornado.ioloop
import tornado.web
class Client(MessagingHandler):
def __init__(self, url):
super(Client, self).__init__()
self.url = url
def on_timer_task(self, event):
print('tick')
self.container.schedule(1, self)
def on_start(self, event):
self.container = event.reactor
self.sender = event.container.create_sender(self.url)
self.receiver =
event.container.create_receiver(self.sender.connection)
#self.container.schedule(1, self)
def on_link_opened(self, event):
print(event)
class ExampleHandler(tornado.web.RequestHandler):
def get(self):
self.write('hello')
loop = tornado.ioloop.IOLoop.instance()
client = Client("localhost:5800")
client.container = Container(client, loop)
client.container.initialise()
app = tornado.web.Application([tornado.web.url(r"/hello", ExampleHandler)])
app.listen(8888)
loop.start()