handle shutdown in receivequeuethread
- sometimes during shutdown, the receivequeuethread would get stuck
This commit is contained in:
parent
391d40d78b
commit
7b470d4b66
|
@ -5,6 +5,7 @@ import time
|
|||
import asyncore_pollchoose as asyncore
|
||||
from debug import logger
|
||||
from helper_threading import BusyError, nonBlocking
|
||||
import state
|
||||
|
||||
class AdvancedDispatcher(asyncore.dispatcher):
|
||||
_buf_len = 2097152 # 2MB
|
||||
|
@ -50,16 +51,17 @@ class AdvancedDispatcher(asyncore.dispatcher):
|
|||
del self.read_buf[0:length]
|
||||
|
||||
def process(self):
|
||||
if not self.connected:
|
||||
return False
|
||||
while True:
|
||||
while self.connected and not state.shutdown:
|
||||
try:
|
||||
with nonBlocking(self.processingLock):
|
||||
if not self.connected or state.shutdown:
|
||||
break
|
||||
if len(self.read_buf) < self.expectBytes:
|
||||
return False
|
||||
if getattr(self, "state_" + str(self.state))() is False:
|
||||
break
|
||||
except AttributeError:
|
||||
logger.error("Unknown state %s", self.state)
|
||||
raise
|
||||
except BusyError:
|
||||
return False
|
||||
|
|
|
@ -30,7 +30,7 @@ class ReceiveQueueThread(threading.Thread, StoppableThread):
|
|||
except Queue.Empty:
|
||||
continue
|
||||
|
||||
if self._stopped:
|
||||
if self._stopped or state.shutdown:
|
||||
break
|
||||
|
||||
# cycle as long as there is data
|
||||
|
|
Reference in New Issue
Block a user