Permalink
Browse files

don't wait for data on read and dispatch

  • Loading branch information...
1 parent c8b5539 commit 26ad073ece5d6889bd088be6e580bf16075cbceb @gestiweb gestiweb committed Mar 8, 2011
Showing with 9 additions and 0 deletions.
  1. +9 −0 bjsonrpc/connection.py
View
@@ -40,6 +40,7 @@
from bjsonrpc.exceptions import EofError, ServerError
import bjsonrpc.jsonlib as json
+import select
class RemoteObject(object):
"""
@@ -432,6 +433,14 @@ def dispatch_until_empty(self):
This method will never block waiting. If there aren't
any more messages that can be processed, it returns.
"""
+ ready_to_read = select.select(
+ [self._sck], # read
+ [], [], # write, errors
+ 0 # timeout
+ )[0]
+
+ if not ready_to_read: return 0
+
newline_idx = 0
count = 0
while newline_idx != -1:

0 comments on commit 26ad073

Please sign in to comment.