From 72897efdcb587221bd8bec5af6ffa57092e8cab7 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Wed, 10 Nov 2010 22:30:38 +0000 Subject: Fixed segfault when setting the agent filter on a closed session. Fixed notification for the connected-broker agent. Added an example console program in c++ to monitor the set of agents. Fixed the Python agent example to more elegantly handle connection failure. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1033763 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/bindings/qmf2/examples/python/agent.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'cpp/bindings/qmf2/examples/python') diff --git a/cpp/bindings/qmf2/examples/python/agent.py b/cpp/bindings/qmf2/examples/python/agent.py index a915ed59b1..d354106042 100755 --- a/cpp/bindings/qmf2/examples/python/agent.py +++ b/cpp/bindings/qmf2/examples/python/agent.py @@ -35,12 +35,14 @@ class ExampleAgent(AgentHandler): ## Create and open a messaging connection to a broker. ## self.connection = cqpid.Connection(url) + self.session = None self.connection.open() ## ## Create, configure, and open a QMFv2 agent session using the connection. ## self.session = AgentSession(self.connection, "{interval:30}") + self.session.setDomain("test") self.session.setVendor('profitron.com') self.session.setProduct('blastinator') self.session.setAttribute('attr1', 1000) @@ -56,7 +58,8 @@ class ExampleAgent(AgentHandler): """ Clean up the session and connection. """ - self.session.close() + if self.session: + self.session.close() self.connection.close() @@ -141,10 +144,13 @@ class ExampleAgent(AgentHandler): self.controlAddr = self.session.addData(self.control, "singleton") +try: + agent = ExampleAgent("localhost") + agent.setupSchema() + agent.populateData() + agent.run() # Use agent.start() to launch the agent in a separate thread + agent.shutdown() +except Exception, e: + print "Exception Caught:", e -agent = ExampleAgent("localhost") -agent.setupSchema() -agent.populateData() -agent.run() # Use agent.start() to launch the agent in a separate thread -agent.shutdown() -- cgit v1.2.1