replace os pipe with multiprocessing (seems to work better)

This commit is contained in:
Jakob Ketterl 2019-09-22 12:56:35 +02:00
parent 1ed69de5b0
commit b4ffc6e2f0

View File

@ -1,7 +1,7 @@
import base64 import base64
import hashlib import hashlib
import json import json
import os from multiprocessing import Pipe
import select import select
import threading import threading
@ -19,7 +19,7 @@ class WebSocketConnection(object):
self.handler = handler self.handler = handler
self.handler.connection.setblocking(0) self.handler.connection.setblocking(0)
self.messageHandler = messageHandler self.messageHandler = messageHandler
(self.interruptPipeRecv, self.interruptPipeSend) = os.pipe() (self.interruptPipeRecv, self.interruptPipeSend) = Pipe(duplex=False)
self.open = True self.open = True
self.sendLock = threading.Lock() self.sendLock = threading.Lock()
my_headers = self.handler.headers.items() my_headers = self.handler.headers.items()
@ -118,7 +118,7 @@ class WebSocketConnection(object):
self.close() self.close()
def interrupt(self): def interrupt(self):
os.write(self.interruptPipeSend, bytes(0x00)) self.interruptPipeSend.send(bytes(0x00))
def read_loop(self): def read_loop(self):
self.open = True self.open = True