Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

maximum sends for plain connection, add "allsent" event

  • Loading branch information...
commit 48d55e6089e0df04f01cd788762d38a6ffa16622 1 parent 58e7b4b
Mark Schloesser authored August 20, 2012

Showing 1 changed file with 8 additions and 3 deletions. Show diff stats Hide diff stats

  1. 11  evnet/__init__.py
11  evnet/__init__.py
@@ -367,8 +367,8 @@ def _writeloop(self):
367 367
 				if len(self.buf) < 16384*2:
368 368
 					self._event('writable')
369 369
 
370  
-		if len(self.buf) and not self.write_watcher.active:
371  
-			self.write_watcher.start()
  370
+		if len(self.buf): self.write_watcher.start()
  371
+		else: self._event('allsent')
372 372
 
373 373
 		self._writing = False
374 374
 
@@ -520,7 +520,9 @@ def _writable(self, watcher, events):
520 520
 
521 521
 	def _writeloop(self):
522 522
 		self._writing = True
523  
-		while not self._closed and len(self.buf):
  523
+		count = 0
  524
+		while not self._closed and len(self.buf) and count < 5:
  525
+			count += 1
524 526
 			try:
525 527
 				ret = self.sock.send(self.buf)
526 528
 			except socket.error as e:
@@ -536,6 +538,9 @@ def _writeloop(self):
536 538
 				if len(self.buf) < 16384*2:
537 539
 					self._event('writable')
538 540
 
  541
+		if len(self.buf): self.write_watcher.start()
  542
+		else: self._event('allsent')
  543
+
539 544
 		self._writing = False
540 545
 
541 546
 	def _readable(self, watcher, events):

0 notes on commit 48d55e6

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