forked from premiere/premiere-libtorrent
proper fix for unit test http proxy handling EAGAIN
This commit is contained in:
parent
793c65cc61
commit
e94df810cb
12
test/http.py
12
test/http.py
|
@ -81,7 +81,7 @@ Qual a diferença entre um proxy Elite, Anónimo e Transparente?
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import socket, thread, select, sys, base64, time
|
import socket, thread, select, sys, base64, time, errno
|
||||||
|
|
||||||
__version__ = '0.1.0 Draft 1'
|
__version__ = '0.1.0 Draft 1'
|
||||||
BUFLEN = 8192
|
BUFLEN = 8192
|
||||||
|
@ -123,15 +123,15 @@ class ConnectionHandler:
|
||||||
self.target.close()
|
self.target.close()
|
||||||
|
|
||||||
def get_base_header(self):
|
def get_base_header(self):
|
||||||
|
retries = 0
|
||||||
while 1:
|
while 1:
|
||||||
try:
|
try:
|
||||||
self.client_buffer += self.client.recv(BUFLEN)
|
self.client_buffer += self.client.recv(BUFLEN)
|
||||||
except Exception, e:
|
except socket.error, e:
|
||||||
print dir(e)
|
err = e.args[0]
|
||||||
print type(e)
|
if (err == errno.EAGAIN or err == errno.EWOULDBLOCK) and retries < 20:
|
||||||
# 35 == EAGAIN
|
|
||||||
if e.errno == 35:
|
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
retries += 1
|
||||||
continue
|
continue
|
||||||
raise e
|
raise e
|
||||||
end = self.client_buffer.find('\r\n\r\n')
|
end = self.client_buffer.find('\r\n\r\n')
|
||||||
|
|
Loading…
Reference in New Issue