summaryrefslogtreecommitdiff
path: root/python/qpid/client.py
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-03-16 20:26:11 +0000
committerAlan Conway <aconway@apache.org>2007-03-16 20:26:11 +0000
commit55a530448b4107edcb3bb8543b562c7208080995 (patch)
tree23be2798e546f641ff4652f7255c090a39cd3010 /python/qpid/client.py
parentf3cb9466b4b969747f97ab6716964179db96f124 (diff)
downloadqpid-python-55a530448b4107edcb3bb8543b562c7208080995.tar.gz
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
Diffstat (limited to 'python/qpid/client.py')
-rw-r--r--python/qpid/client.py21
1 files changed, 11 insertions, 10 deletions
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()