Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

only not blocking on the 1 needed recv call. let sendall do its thing.

  • Loading branch information...
commit 2b4a46cf13b8e7a53201a07d26ee7f1fa39c5e9c 1 parent 141e3ab
BuzzTroll authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 lantorrent/pylantorrent/ltConnection.py
7 lantorrent/pylantorrent/ltConnection.py
View
@@ -45,7 +45,6 @@ def __init__(self, json_ent, output_printer, data_transform=None):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((self.host, self.port))
self.socket = s
- self.socket.setblocking(0)
except Exception, ex:
vex = LTException(505, "%s:%d" % (self.host, self.port), self.host, self.port, reqs=self.requests)
pylantorrent.log(logging.ERROR, str(vex), traceback)
@@ -79,16 +78,18 @@ def send_header(self, destinations):
self.send(send_str)
self.send("EOH : %s\r\n" % (signature))
- def _poll(self, poll_period=0):
+ def _poll(self, poll_period=0.0):
if not self.valid:
return
try:
+ self.socket.settimeout(poll_period)
data = self._read_from_socket(self.read_buffer_len)
if data:
self.output_printer.print_results(data)
except:
# there may jsut be no data now
pass
+ self.socket.settimeout(None)
def _read_from_socket(self, size):
data = self.socket.recv(size)
@@ -100,7 +101,7 @@ def _write_to_socket(self, data):
def read_to_eof(self):
if not self.valid:
return
- self.socket.setblocking(1)
+ self.socket.settimeout(None)
data = self._read_from_socket(self.read_buffer_len)
while data:
self.output_printer.print_results(data)
Please sign in to comment.
Something went wrong with that request. Please try again.