[ 
https://issues.apache.org/jira/browse/PROTON-2111?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16995835#comment-16995835
 ] 

Andrew Stitcher commented on PROTON-2111:
-----------------------------------------

This is a rather strange way to publish a message is there a reason why you 
don't use the BlockingConnection/BlockingSender etc?

The proton.Container class is intended to be one per application and no design 
effect was spent to allow you to have multiple a indefinite number of 
Containers. That is not to say it couldn't be done or even that it would be 
overly hard, but in usual applications it is not needed.

Is there an overriding reason why your real application can't have a single 
Container and just create new senders with the appropriate handler when you 
need to send messages?

> python: memory leak on Container, SSL, and SSLDomain objects
> ------------------------------------------------------------
>
>                 Key: PROTON-2111
>                 URL: https://issues.apache.org/jira/browse/PROTON-2111
>             Project: Qpid Proton
>          Issue Type: Bug
>          Components: python-binding
>            Reporter: Chenxiong Qi
>            Priority: Major
>
> I have an application using qpid.proton to interact with ActiveMQ broker to 
> publish messages. Following is a fake script showing an example of the app 
> works to send a message.
> {noformat}
> class SampleSender(proton.handlers.MessagingHandler):
>     def __init__(self, msg_id, *args, **kwargs):
>         super(SampleSender, self).__init__(*args, **kwargs)
>         self.msg_id = msg_id
>     def on_start(self, event):
>         ssl_domain = proton.SSLDomain(proton.SSLDomain.MODE_CLIENT)
>         ssl_domain.set_credentials(producer_config['certificate'],
>                                    producer_config['private_key'],
>                                    None)
>         ssl_domain.set_trusted_ca_db(producer_config['trusted_certificates'])
>         ssl_domain.set_peer_authentication(proton.SSLDomain.VERIFY_PEER)
>         conn = event.container.connect(urls=producer_config['urls'],
>                                        reconnect=False,
>                                        ssl_domain=ssl_domain)
>         event.container.create_sender(conn, 
> target='topic://VirtualTopic.event')
>     def on_sendable(self, event):
>         msg = proton.Message(body={'msg-id': self.msg_id, 'name': 'python'})
>         event.sender.send(msg)
>         event.sender.close()
>         event.connection.close()
> def send_msg(msg_id):
>     container = proton.reactor.Container(SampleSender(msg_id))
>     container.run()
> objgraph.show_growth()
> for i in range(3):
>     send_msg(i + 1)
> new_ids = objgraph.get_new_ids()
> print(objgraph.at_addrs(new_ids['SSLDomain']))
> print(objgraph.at_addrs(new_ids['Container']))
> print(objgraph.at_addrs(new_ids['SSL']))
> {noformat}
> Each time to publish a message, a new Container object is created and a new 
> handler object is created and passed to that container. After the code runs 
> several times, Container, SSL and SSLDomain objects remain in memory and are 
> not collected. I use objgraph to find out those objects.
> I'm using Fedora 30 and python-qpid-proton 0.28.0.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to