[Ironpython-users] requests hang on get or post http request

Daniel Fernandez fernandez_dan2 at hotmail.com
Thu Aug 21 18:37:49 CEST 2014


Hi All,
I'm using the latest 2.7.5 b3 code and I wanted to see if requests works. I pulled the latest from github. It would hang on simple requests.get or requests.post. It would hang on the reading the http response.  I attached the debugger and traced it to PythonBinaryReader:Read method. in the PythonFile.cs  It hangs when size = 0. It hangs specifically in this loop
int leftCount = size; while (true) {                int count = _stream.Read(data, offset, leftCount);                if (count <= 0) break;                leftCount -= count;                if (leftCount <= 0) break;                offset += count;            }
It hangs on the _stream.read where offset is  0 and leftCount is zero and the stream is a NetworkStream. 

I looked at the PythonTextCRLFReader, PythonTextCRReader, PythonTextLFReader, and PythonUniversalReader in the same PythonFile.cs. It looks like they all have a way to handle when size is equal 0 or less. 
I ran a quick experiment and just added one line, didn't want to change too much. I changed. 
int leftCount = size;while (true) {
                if (leftCount <= 0) break;                int count = _stream.Read(data, offset, leftCount);                if (count <= 0) break;                leftCount -= count;                if (leftCount <= 0) break;                offset += count;            }

After this I was able to get all HTTP GETs and POSTs working. I did this with rest type calls and normal web transactions. 
I was just wanted to check if any ran into this issue before? I'm not sure if this was just a me thing. 

Danny

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20140821/3bb78bd9/attachment.html>


More information about the Ironpython-users mailing list