From e18a6d2a6b3dd22fb68908861387beb466cc4afe Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Mon, 26 Apr 2010 14:07:01 +0000
Subject: [PATCH] Test if there are pending message when looping.

This prevents from having an endless wait on "get" if the last connection
from which we were expecting answers got interrupted.
Note that this method will not raise any error related to this.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2028 71dcc9de-d417-0410-9af5-da40c76e7ee4
---
 neo/client/app.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/neo/client/app.py b/neo/client/app.py
index 09e2628e..e203563d 100644
--- a/neo/client/app.py
+++ b/neo/client/app.py
@@ -212,9 +212,11 @@ class Application(object):
             If True (default), will block until at least one packet was
             received.
         """
-        get = self.local_var.queue.get
+        pending = self.dispatcher.pending
+        queue = self.local_var.queue
+        get = queue.get
         _handlePacket = self._handlePacket
-        while True:
+        while pending(queue):
             try:
                 conn, packet = get(block)
             except Empty:
-- 
2.30.9