mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #3631 from lovedboy/master
little modification in consume_socket_content
This commit is contained in:
@@ -8,17 +8,17 @@ import select
|
||||
def consume_socket_content(sock, timeout=0.5):
|
||||
chunks = 65536
|
||||
content = b''
|
||||
more_to_read = select.select([sock], [], [], timeout)[0]
|
||||
|
||||
while more_to_read:
|
||||
while True:
|
||||
more_to_read = select.select([sock], [], [], timeout)[0]
|
||||
if not more_to_read:
|
||||
break
|
||||
|
||||
new_content = sock.recv(chunks)
|
||||
|
||||
if not new_content:
|
||||
break
|
||||
|
||||
content += new_content
|
||||
# stop reading if no new data is received for a while
|
||||
more_to_read = select.select([sock], [], [], timeout)[0]
|
||||
|
||||
return content
|
||||
|
||||
|
||||
Reference in New Issue
Block a user