From dcc181bf75f4cac0288d300ceb235810ada93803 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Mon, 10 Jul 2017 23:18:58 +0200 Subject: [PATCH] Asyncore processing thread synchronisation - threre was a synchronisation problem where one thread could process more data than another thread was expecting, leading to the thread crashing --- src/network/advanceddispatcher.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/network/advanceddispatcher.py b/src/network/advanceddispatcher.py index 1c33f376..005aa038 100644 --- a/src/network/advanceddispatcher.py +++ b/src/network/advanceddispatcher.py @@ -43,9 +43,12 @@ class AdvancedDispatcher(asyncore.dispatcher): def process(self): if not self.connected: return False - while len(self.read_buf) >= self.expectBytes: + loop = 0 + while True: try: with nonBlocking(self.processingLock): + if len(self.read_buf) < self.expectBytes: + return False if getattr(self, "state_" + str(self.state))() is False: break except AttributeError: