Uploaded image for project: 'Qpid Proton'
  1. Qpid Proton
  2. PROTON-2404

[python] Tornado container does not work with both timer and connection

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • proton-c-0.34.0
    • None
    • examples, python-binding
    • None

    Description

      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. With the below example tornado server works fine but I am not able to run both timer 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. Although it is just an example I think it is essential to be able to combine the amqp event loop with event loops in other libraries. It would be good to also have a container based on asyncio.
       

      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()
      

       

      Attachments

        Activity

          People

            astitcher Andrew Stitcher
            megahallon Fredrik Hallenberg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: