shut down pipes correctly, refs #146
This commit is contained in:
parent
c54f19282a
commit
369a61ec59
@ -146,6 +146,9 @@ class WebSocketConnection(object):
|
|||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def interrupt(self):
|
def interrupt(self):
|
||||||
|
if self.interruptPipeSend is None:
|
||||||
|
logger.debug("interrupt with closed pipe")
|
||||||
|
return
|
||||||
self.interruptPipeSend.send(bytes(0x00))
|
self.interruptPipeSend.send(bytes(0x00))
|
||||||
|
|
||||||
def handle(self):
|
def handle(self):
|
||||||
@ -227,6 +230,18 @@ class WebSocketConnection(object):
|
|||||||
logger.exception("OSError while reading data; closing connection")
|
logger.exception("OSError while reading data; closing connection")
|
||||||
self.open = False
|
self.open = False
|
||||||
|
|
||||||
|
self.interruptPipeSend.close()
|
||||||
|
self.interruptPipeSend = None
|
||||||
|
# drain messages left in the queue so that the queue can be successfully closed
|
||||||
|
# this is necessary since python keeps the file descriptors open otherwise
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
self.interruptPipeRecv.recv()
|
||||||
|
except EOFError:
|
||||||
|
pass
|
||||||
|
self.interruptPipeRecv.close()
|
||||||
|
self.interruptPipeRecv = None
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.open = False
|
self.open = False
|
||||||
self.interrupt()
|
self.interrupt()
|
||||||
|
Loading…
Reference in New Issue
Block a user