From b5b72ac81720d884ee441b699066a82de3bd8f8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Wisniewski?= <gregory@nexedi.com> Date: Fri, 22 Jan 2010 10:45:45 +0000 Subject: [PATCH] Remove try/except block that hide an exception without explanations. KeyError may be raised from many statements here, the try/except give no indications. Also reduce block indentation for readability and add some comments. git-svn-id: https://svn.erp5.org/repos/neo/trunk@1469 71dcc9de-d417-0410-9af5-da40c76e7ee4 --- neo/master/handlers/storage.py | 61 +++++++++++++++++----------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/neo/master/handlers/storage.py b/neo/master/handlers/storage.py index 413a92af..2e712f6d 100644 --- a/neo/master/handlers/storage.py +++ b/neo/master/handlers/storage.py @@ -60,37 +60,36 @@ class StorageServiceHandler(BaseServiceHandler): if tid > self.app.tm.getLastTID(): raise UnexpectedPacketError - try: - t = self.app.tm[tid] - if t.lock(uuid): # all nodes are locked - # XXX: review needed: - # don't iterate over connections but search by uuid - # include client's uuid in Transaction object - - # I have received all the answers now. So send a Notify - # Transaction Finished to the initiated client node, - # Invalidate Objects to the other client nodes, and Unlock - # Information to relevant storage nodes. - for c in app.em.getConnectionList(): - uuid = c.getUUID() - if uuid is not None: - node = app.nm.getByUUID(uuid) - if node.isClient(): - if node is t.getNode(): - p = Packets.NotifyTransactionFinished(tid) - c.answer(p, t.getMessageId()) - else: - p = Packets.InvalidateObjects(t.getOIDList(), - tid) - c.notify(p) - elif node.isStorage(): - if uuid in t.getUUIDList(): - p = Packets.UnlockInformation(tid) - c.notify(p) - self.app.tm.remove(tid) - except KeyError: - # What is this? - pass + # transaction locked on this storage node + t = self.app.tm[tid] + if not t.lock(uuid): + return + + # all nodes are locked + # XXX: review needed: + # don't iterate over connections but search by uuid + # include client's uuid in Transaction object + + # I have received all the answers now. So send a Notify + # Transaction Finished to the initiated client node, + # Invalidate Objects to the other client nodes, and Unlock + # Information to relevant storage nodes. + for c in app.em.getConnectionList(): + uuid = c.getUUID() + if uuid is not None: + node = app.nm.getByUUID(uuid) + if node.isClient(): + if node is t.getNode(): + p = Packets.NotifyTransactionFinished(tid) + c.answer(p, t.getMessageId()) + else: + c.notify(Packets.InvalidateObjects(t.getOIDList(), tid)) + elif node.isStorage(): + if uuid in t.getUUIDList(): + c.notify(Packets.UnlockInformation(tid)) + + # remove transaction from manager + self.app.tm.remove(tid) def notifyReplicationDone(self, conn, packet, offset): uuid = conn.getUUID() -- 2.30.9