Commit b29063a5 authored by Jeremy Hylton's avatar Jeremy Hylton

Add a close() method to the ZEOStorage that closes connection to client.

XXX If select() raises an exception inside asyncore, close the connection.
parent f70d357b
...@@ -118,11 +118,16 @@ class ZEOStorage: ...@@ -118,11 +118,16 @@ class ZEOStorage:
def __init__(self, server): def __init__(self, server):
self.server = server self.server = server
self.client = None self.client = None
self._conn = None # the connection associated with client
self.__storage = None self.__storage = None
self.__storage_id = "uninitialized" self.__storage_id = "uninitialized"
self._transaction = None self._transaction = None
def close(self):
self._conn.close()
def notifyConnected(self, conn): def notifyConnected(self, conn):
self._conn = conn
self.client = ClientStub.ClientStorage(conn) self.client = ClientStub.ClientStorage(conn)
def __repr__(self): def __repr__(self):
......
...@@ -325,7 +325,12 @@ class Connection(smac.SizedMessageAsyncConnection): ...@@ -325,7 +325,12 @@ class Connection(smac.SizedMessageAsyncConnection):
# Do loop only if lock is already acquired. XXX But can't # Do loop only if lock is already acquired. XXX But can't
# we already guarantee that the lock is already acquired? # we already guarantee that the lock is already acquired?
while not self.__reply_lock.acquire(0): while not self.__reply_lock.acquire(0):
asyncore.poll(10.0, self._map) try:
asyncore.poll(10.0, self._map)
except select.error, err:
log("Closing. asyncore.poll() raised %s." % err,
level=zLOG.BLATHER)
self.close()
if self.closed: if self.closed:
raise DisconnectedError() raise DisconnectedError()
self.__reply_lock.release() self.__reply_lock.release()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment