Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

TCP_NODELAY for better latency

  • Loading branch information...
commit e921a1415ef58920847a4980960f29ba46400315 1 parent 06063ca
Paolo Losi authored

Showing 2 changed files with 4 additions and 3 deletions. Show diff stats Hide diff stats

  1. +3 1 stormed/connection.py
  2. +1 2  stormed/frame.py
4 stormed/connection.py
@@ -38,7 +38,9 @@ def connect(self, callback):
38 38 if self.status is not status.CLOSED:
39 39 raise Exception('Connection status is %s' % self.status)
40 40 self.status = status.OPENING
41   - self.stream = IOStream(socket.socket(), io_loop=self.io_loop)
  41 + sock = socket.socket()
  42 + sock.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1)
  43 + self.stream = IOStream(sock, io_loop=self.io_loop)
42 44 self.stream.connect((self.host, self.port), self._handshake)
43 45 self.stream.set_close_callback(self.on_closed_stream)
44 46 self.on_connect = callback
3  stormed/frame.py
@@ -167,8 +167,7 @@ def write_msg(self, msg):
167 167 frames = []
168 168 frames.append(content_header_from_msg(msg, self.channel_id))
169 169 frames.extend(body_frames_from_msg(msg, self.channel_id))
170   - for f in frames:
171   - self.conn.stream.write(f)
  170 + self.conn.stream.write(''.join(frames))
172 171
173 172 def hard_reset(self):
174 173 self.status = status.CLOSED

0 comments on commit e921a14

Please sign in to comment.
Something went wrong with that request. Please try again.