From 55a530448b4107edcb3bb8543b562c7208080995 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Fri, 16 Mar 2007 20:26:11 +0000 Subject: Merged revisions 496593 via svnmerge from https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9 ........ r496593 | rhs | 2007-01-16 00:28:25 -0500 (Tue, 16 Jan 2007) | 1 line 0-9 request/response framing for python ........ git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@519129 13f79535-47bb-0310-9956-ffa450edef68 --- python/qpid/client.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'python/qpid/client.py') diff --git a/python/qpid/client.py b/python/qpid/client.py index b4a282f251..3083cd4933 100644 --- a/python/qpid/client.py +++ b/python/qpid/client.py @@ -25,7 +25,7 @@ interacting with the server. import threading from peer import Peer, Closed from delegate import Delegate -from connection import Connection, Frame +from connection import Connection, Frame, connect from spec import load from queue import Queue @@ -49,15 +49,13 @@ class Client: self.lock = threading.Lock() self.closed = False + self.reason = None self.started = threading.Event() - self.conn = Connection(self.host, self.port, self.spec) - self.peer = Peer(self.conn, ClientDelegate(self)) - def wait(self): self.started.wait() if self.closed: - raise EOFError() + raise Closed(self.reason) def queue(self, key): self.lock.acquire() @@ -76,7 +74,9 @@ class Client: self.response = response self.locale = locale - self.conn.connect() + self.conn = Connection(connect(self.host, self.port), self.spec) + self.peer = Peer(self.conn, ClientDelegate(self)) + self.conn.init() self.peer.start() self.wait() @@ -92,12 +92,12 @@ class ClientDelegate(Delegate): self.client = client def connection_start(self, ch, msg): - ch.connection_start_ok(mechanism=self.client.mechanism, - response=self.client.response, - locale=self.client.locale) + msg.start_ok(mechanism=self.client.mechanism, + response=self.client.response, + locale=self.client.locale) def connection_tune(self, ch, msg): - ch.connection_tune_ok(*msg.fields) + msg.tune_ok(*msg.frame.args) self.client.started.set() def basic_deliver(self, ch, msg): @@ -111,4 +111,5 @@ class ClientDelegate(Delegate): def close(self, reason): self.client.closed = True + self.client.reason = reason self.client.started.set() -- cgit v1.2.1