[issue21878] wsgi.simple_server's wsgi.input read/readline waits forever in certain circumstances

2017-06-02 Thread Dom Cote

Dom Cote added the comment:

Just bumped into this issue today using bobo.

On the first attempt to load a page, it's OK, because there is something to 
read. But if you hit the "reload" button on the browser, for some reason, it 
will connect with the server a second time after the request is completed, and 
but there nothing is being sent, so readline() never comes back.

However, the documentation says that if the underlying object is set as 
non-blocking, then it shouldn't block.

So I first inspected the timeout value on the request's socket, and it comes 
back 0.0, which according to the sockets doc, should mean non blocking. That's 
weird.

So I decided to go ahead and call the setblocking(False) on the socket anyway, 
and this time, readline() came back with no data. The rest took care of itself.

This is my debug traces as well as a small patch to show the workaround.

Notice how the timeout is comes back as 0.0 despite the fact that the socket 
will block.

Also, notice the second connection request being '' after putting in the fix.

==

>  laddr=('192.168.1.113', 8085), raddr=('192.168.1.6', 59194)> 0.0
7> b'GET / HTTP/1.1\r\n'
192.168.1.6 - - [02/Jun/2017 16:01:39] "GET / HTTP/1.1" 200 690
5>  0.0
6>  0.0
7> b''

diff --git a/simple_server.py b/simple_server.py
index 7fddbe8..3df4ffa 100644
--- a/simple_server.py
+++ b/simple_server.py
@@ -115,9 +115,13 @@ class WSGIRequestHandler(BaseHTTPRequestHandler):

 def handle(self):
 """Handle a single HTTP request"""
-
+print("5>",self.connection,self.connection.gettimeout())
+self.connection.setblocking(False)
 self.raw_requestline = self.rfile.readline(65537)
-if len(self.raw_requestline) > 65536:
+print("6>",self.connection,self.connection.gettimeout())
+print("7>",str(self.raw_requestline))
+
+if False and len(self.raw_requestline) > 65536:
 self.requestline = ''
 self.request_version = ''
 self.command = ''

--
nosy: +buzdelabuz2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21878] wsgi.simple_server's wsgi.input read/readline waits forever in certain circumstances

2016-09-22 Thread Bert JW Regeer

Bert JW Regeer added the comment:

This is still very much an issue, and makes it more difficult to write generic 
python request/response libraries because we can't assume that a read() will 
return, and relying on the Content-Length being set is not always possible 
unfortunately.

--
nosy: +X-Istence
versions: +Python 2.7, Python 3.3, Python 3.4, Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21878] wsgi.simple_server's wsgi.input read/readline waits forever in certain circumstances

2016-02-19 Thread tzickel

tzickel added the comment:

Just encountered this issue as well.

It's not related to newlines, but to not supporting HTTP or persistent 
connections (the wsgi.input is the socket's I/O directly, and if the client 
serves a persistent connection, then the .read() will block forever).

A simple solution is to use a saner wsgi server (gevent works nicely).
Here is their implmentation of the socket I/O wrapper class (Input), and it's 
read/readlines functions:
https://github.com/gevent/gevent/blob/a65501a1270c1763e9de336a9c3cf52081223ff6/gevent/pywsgi.py#L303

--
nosy: +tzickel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21878] wsgi.simple_server's wsgi.input read/readline waits forever in certain circumstances

2014-06-29 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
nosy: +pje

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21878
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21878] wsgi.simple_server's wsgi.input read/readline waits forever in certain circumstances

2014-06-28 Thread Robin Schoonover

Robin Schoonover added the comment:

Issue also occurs if .read() is used with no size.

--
title: wsgi.simple_server's wsgi.input readline waits forever for 
non-multipart/form-data - wsgi.simple_server's wsgi.input read/readline waits 
forever in certain circumstances

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21878
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com