diff options
author | Rafael H. Schloming <rhs@apache.org> | 2009-01-08 18:27:39 +0000 |
---|---|---|
committer | Rafael H. Schloming <rhs@apache.org> | 2009-01-08 18:27:39 +0000 |
commit | 5f5b7cbf6a266ae471c32b07457e38a7f11cdf46 (patch) | |
tree | db58078e0f88220fb0388ca1662b5ba9a9763035 | |
parent | 64bd79537e385a045b3c74de95ddd19f91163a26 (diff) | |
download | qpid-python-5f5b7cbf6a266ae471c32b07457e38a7f11cdf46.tar.gz |
ignore hearbeat controls rather than barfing on them, also permit the heartbeat to be specified on connection creation
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@732778 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | python/qpid/delegates.py | 9 | ||||
-rw-r--r-- | python/tests/connection.py | 17 |
2 files changed, 19 insertions, 7 deletions
diff --git a/python/qpid/delegates.py b/python/qpid/delegates.py index bf26553dda..61c8e8c326 100644 --- a/python/qpid/delegates.py +++ b/python/qpid/delegates.py @@ -61,6 +61,9 @@ class Delegate: self.connection.opened = False notify(self.connection.condition) + def connection_heartbeat(self, ch, hrt): + pass + def session_attach(self, ch, a): try: self.connection.attach(a.name, ch, self.delegate, a.force) @@ -139,11 +142,13 @@ class Client(Delegate): "version": "development", "platform": os.name} - def __init__(self, connection, username="guest", password="guest", mechanism="PLAIN"): + def __init__(self, connection, username="guest", password="guest", + mechanism="PLAIN", heartbeat=None): Delegate.__init__(self, connection) self.username = username self.password = password self.mechanism = mechanism + self.heartbeat = heartbeat def start(self): self.connection.write_header(self.spec.major, self.spec.minor) @@ -154,7 +159,7 @@ class Client(Delegate): ch.connection_start_ok(client_properties=Client.PROPERTIES, mechanism=self.mechanism, response=r) def connection_tune(self, ch, tune): - ch.connection_tune_ok() + ch.connection_tune_ok(heartbeat=self.heartbeat) ch.connection_open() def connection_open_ok(self, ch, open_ok): diff --git a/python/tests/connection.py b/python/tests/connection.py index 512fa62189..19cdad9f97 100644 --- a/python/tests/connection.py +++ b/python/tests/connection.py @@ -25,7 +25,6 @@ from qpid.datatypes import Message from qpid.testlib import testrunner from qpid.delegates import Server from qpid.queue import Queue -from qpid.spec010 import load from qpid.session import Delegate PORT = 1234 @@ -62,13 +61,14 @@ class TestSession(Delegate): cmd.acquire_mode, m) elif cmd.destination == "abort": self.session.channel.connection.sock.close() + elif cmd.destination == "heartbeat": + self.session.channel.connection_heartbeat() else: self.queue.put((cmd, headers, body)) class ConnectionTest(TestCase): def setUp(self): - self.spec = load(testrunner.get_spec_file("amqp.0-10.xml")) self.queue = Queue() self.running = True started = Event() @@ -76,7 +76,7 @@ class ConnectionTest(TestCase): def run(): ts = TestServer(self.queue) for s in listen("0.0.0.0", PORT, lambda: self.running, lambda: started.set()): - conn = Connection(s, self.spec, ts.connection) + conn = Connection(s, delegate=ts.connection) try: conn.start(5) except Closed: @@ -94,8 +94,8 @@ class ConnectionTest(TestCase): connect("0.0.0.0", PORT).close() self.server.join(3) - def connect(self): - return Connection(connect("0.0.0.0", PORT), self.spec) + def connect(self, **kwargs): + return Connection(connect("0.0.0.0", PORT), **kwargs) def test(self): c = self.connect() @@ -213,3 +213,10 @@ class ConnectionTest(TestCase): s.auto_sync = False s.message_transfer("echo", message=Message("test")) s.sync(10) + + def testHeartbeat(self): + c = self.connect(heartbeat=10) + c.start(10) + s = c.session("test") + s.channel.connection_heartbeat() + s.message_transfer("heartbeat") |