[Neo-report] r2642 vincent - in /trunk/neo: client/app.py lib/dispatcher.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Jan 25 14:44:13 CET 2011
Author: vincent
Date: Tue Jan 25 14:44:13 2011
New Revision: 2642
Log:
Extend r2641.
Move queue flushing to dispatcher.
Use forget_queue in "undo" as well.
Modified:
trunk/neo/client/app.py
trunk/neo/lib/dispatcher.py
Modified: trunk/neo/client/app.py
==============================================================================
--- trunk/neo/client/app.py [iso-8859-1] (original)
+++ trunk/neo/client/app.py [iso-8859-1] Tue Jan 25 14:44:13 2011
@@ -817,11 +817,6 @@ class Application(object):
self._getMasterConnection().notify(p)
queue = self.local_var.queue
self.dispatcher.forget_queue(queue)
- while True:
- try:
- queue.get(block=False)
- except Empty:
- break
self.local_var.clear()
@profiler_decorator
@@ -917,16 +912,11 @@ class Application(object):
# Wait for all AnswerObjectUndoSerial. We might get OidNotFoundError,
# meaning that objects in transaction's oid_list do not exist any
# longer. This is the symptom of a pack, so forbid undoing transaction
- # when it happens, but sill keep waiting for answers.
- failed = False
- while True:
- try:
- self.waitResponses()
- except NEOStorageNotFoundError:
- failed = True
- else:
- break
- if failed:
+ # when it happens.
+ try:
+ self.waitResponses()
+ except NEOStorageNotFoundError:
+ self.dispatcher.forget_queue(queue)
raise UndoError('non-undoable transaction')
# Send undo data to all storage nodes.
Modified: trunk/neo/lib/dispatcher.py
==============================================================================
--- trunk/neo/lib/dispatcher.py [iso-8859-1] (original)
+++ trunk/neo/lib/dispatcher.py [iso-8859-1] Tue Jan 25 14:44:13 2011
@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-from neo.lib.locking import Lock
+from neo.lib.locking import Lock, Empty
from neo.lib.profiling import profiler_decorator
EMPTY = {}
NOBODY = []
@@ -133,11 +133,13 @@ class Dispatcher:
@giant_lock
@profiler_decorator
- def forget_queue(self, queue):
+ def forget_queue(self, queue, flush_queue=True):
"""
Forget all pending messages for given queue.
Actually makes them "expected by nobody", so we know we can ignore
them, and not detect it as an error.
+ flush_queue (boolean, default=True)
+ All packets in queue get flushed.
"""
# XXX: expensive lookup: we iterate over the whole dict
found = 0
@@ -150,6 +152,13 @@ class Dispatcher:
if refcount != found:
raise ValueError('We hit a refcount bug: %s queue uses ' \
'expected, %s found' % (refcount, found))
+ if flush_queue:
+ get = queue.get
+ while True:
+ try:
+ get(block=False)
+ except Empty:
+ break
@profiler_decorator
def registered(self, conn):
More information about the Neo-report
mailing list