You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Fredrik Hallenberg (Jira)" <ji...@apache.org> on 2021/07/01 09:02:00 UTC
[jira] [Updated] (PROTON-2404) [python] Tornado container does not
work with both timer and connection
[ https://issues.apache.org/jira/browse/PROTON-2404?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Fredrik Hallenberg updated PROTON-2404:
---------------------------------------
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()
was:
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 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()
Summary: [python] Tornado container does not work with both timer and connection (was: [python] Tornado container does not work both timer and connection)
> [python] Tornado container does not work with both timer and connection
> -----------------------------------------------------------------------
>
> Key: PROTON-2404
> URL: https://issues.apache.org/jira/browse/PROTON-2404
> Project: Qpid Proton
> Issue Type: Bug
> Components: examples
> Reporter: Fredrik Hallenberg
> Assignee: Andrew Stitcher
> Priority: Major
>
> 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()
>
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org