From eeeb2b0657c395ade790d5f16e673f277b000e11 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Sun, 20 May 2012 02:24:30 +0400 Subject: [PATCH 1/1] fix socket send; increase buffer --- transports/stratum_tcp.py | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/transports/stratum_tcp.py b/transports/stratum_tcp.py index bd7cdae..85fc8b7 100644 --- a/transports/stratum_tcp.py +++ b/transports/stratum_tcp.py @@ -27,13 +27,15 @@ class TcpSession(Session): self._stopped = True def send_response(self, response): - raw_response = json.dumps(response) + data = json.dumps(response) + "\n" # Possible race condition here by having session # close connection? # I assume Python connections are thread safe interfaces try: connection = self.connection() - connection.send(raw_response + "\n") + while data: + l = connection.send(data) + data = data[l:] except: self.stop() @@ -68,7 +70,7 @@ class TcpClientRequestor(threading.Thread): def receive(self): try: - return self.session.connection().recv(1024) + return self.session.connection().recv(2048) except: return '' -- 1.7.1