From f51c2b0f95b3d4150bb423b1d12c6dd268a820be Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Sun, 31 Jul 2005 17:18:27 +0000 Subject: [PATCH] initial patch: do not throw all xml at once to parser because that freezes UI until process is finished. TODO: a better way to seperate what is left to seperate and send by smaller chunks to parser --- src/common/xmpp/dispatcher.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/common/xmpp/dispatcher.py b/src/common/xmpp/dispatcher.py index 4a05bde8f..c96125930 100644 --- a/src/common/xmpp/dispatcher.py +++ b/src/common/xmpp/dispatcher.py @@ -32,6 +32,7 @@ class Dispatcher(PlugIn): """ Ancestor of PlugIn class. Handles XMPP stream, i.e. aware of stream headers. Can be plugged out/in to restart these headers (used for SASL f.e.). """ def __init__(self): + self.in_buffer='' PlugIn.__init__(self) DBG_LINE='dispatcher' self.handlers={} @@ -110,8 +111,13 @@ class Dispatcher(PlugIn): 3) 0 (zero) if underlying connection is closed.""" for handler in self._cycleHandlers: handler(self) if self._owner.Connection.pending_data(timeout): - data=self._owner.Connection.receive() - self.Stream.Parse(data) + if not self.in_buffer: + try: self.in_buffer=self._owner.Connection.receive() + except IOError: return + data = self.in_buffer[:1024] # parse first 1 MB + self.Stream.Parse(data) + self.in_buffer=self.in_buffer[1024:] # parse the rest next time + #if data: return len(data) return '0' # It means that nothing is received but link is alive.