fix socket send; increase buffer
authorThomasV <thomasv@gitorious>
Sat, 19 May 2012 22:24:30 +0000 (02:24 +0400)
committerThomasV <thomasv@gitorious>
Sat, 19 May 2012 22:24:30 +0000 (02:24 +0400)
transports/stratum_tcp.py

index bd7cdae..85fc8b7 100644 (file)
@@ -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 ''