From c5d4633df5c3132e969ca41fa122886de9a86d38 Mon Sep 17 00:00:00 2001 From: Louie Lu Date: 2017年7月18日 13:02:54 +0800 Subject: [PATCH] IDLE shell test --- Lib/idlelib/rpc.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Lib/idlelib/rpc.py b/Lib/idlelib/rpc.py index 8f57edb836..8da787038a 100644 --- a/Lib/idlelib/rpc.py +++ b/Lib/idlelib/rpc.py @@ -64,7 +64,7 @@ class CodePickler(pickle.Pickler): dispatch_table.update(copyreg.dispatch_table) -BUFSIZE = 8*1024 +BUFSIZE = 1024 LOCALHOST = '127.0.0.1' class RPCServer(socketserver.TCPServer): @@ -222,6 +222,10 @@ class SocketIO(object): def asynccall(self, oid, methodname, args, kwargs): request = ("CALL", (oid, methodname, args, kwargs)) + + if methodname == 'write' and len(args[0])> BUFSIZE: + return self._chunk_asynccall(oid, methodname, args, kwargs) + seq = self.newseq() if threading.current_thread() != self.sockthread: cvar = threading.Condition() @@ -230,6 +234,22 @@ class SocketIO(object): self.putmessage((seq, request)) return seq + def _chunk_asynccall(self, oid, methodname, args, kwargs): + s = args[0] + while len(s): + chunk = s[:BUFSIZE] + seq = self.newseq() + request = ('CALL', (oid, methodname, (chunk, args[1]), kwargs)) + if threading.current_thread() != self.sockthread: + cvar = threading.Condition() + self.cvars[seq] = cvar + + self.debug(("asynccall:%d:" % seq), oid, methodname, (chunk, args[1]), kwargs) + self.putmessage((seq, request)) + s = s[BUFSIZE:] + + return seq + def asyncqueue(self, oid, methodname, args, kwargs): request = ("QUEUE", (oid, methodname, args, kwargs)) seq = self.newseq() @@ -309,7 +329,7 @@ class SocketIO(object): if response is not None: return response else: - # wait for notification from socket handling thread + # wait for notification from socket handling threadpollresponse cvar = self.cvars[myseq] cvar.acquire() while myseq not in self.responses: @@ -502,7 +522,7 @@ class RemoteProxy(object): class RPCHandler(socketserver.BaseRequestHandler, SocketIO): - debugging = False + debugging = True location = "#S" # Server def __init__(self, sock, addr, svr): @@ -520,7 +540,7 @@ class RPCHandler(socketserver.BaseRequestHandler, SocketIO): class RPCClient(SocketIO): - debugging = False + debugging = True location = "#C" # Client nextseq = 1 # Requests coming from the client are odd numbered -- 2.13.2

AltStyle によって変換されたページ (->オリジナル) /