Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

Add nonblocking server #325

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Prev Previous commit
Next Next commit
fix broken pipe while read 0 byte
  • Loading branch information
wallezhang committed Jan 23, 2018

Unverified

No user is associated with the committer email.
commit 36b8da0fedb823941c30d786c0abf54ab631fcc9
7 changes: 4 additions & 3 deletions thriftpy/nonblockingserver.py
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
import struct
import threading
import ssl
import multiprocessing

from six.moves import queue

@@ -222,9 +223,9 @@ class TNonblockingServer(object):
def __init__(self,
processor,
lsocket,
threads,
inputProtocolFactory=None,
outputProtocolFactory=None,
threads=10):
outputProtocolFactory=None):
self.processor = processor
self.socket = lsocket
self.in_protocol = inputProtocolFactory or TBinaryProtocolFactory()
@@ -312,7 +313,7 @@ def handle(self):
else:
connection = self.clients[readable]
connection.read()
if isinstance(connection.socket, ssl.SSLSocket) and connection.status in (WAIT_LEN, WAIT_MESSAGE):
while isinstance(connection.socket, ssl.SSLSocket) and connection.socket.pending() > 0:
connection.read()
if connection.status == WAIT_PROCESS:
itransport = TMemoryBuffer(connection.message)