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
This commit is contained in:
Peter Šurda 2017-07-10 23:18:58 +02:00
parent f6d5d93bf2
commit dcc181bf75
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -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: