[New-bugs-announce] [issue3826] Self-reference in BaseHTTPRequestHandler descendants causes stuck connections

romkyns report at bugs.python.org
Tue Sep 9 23:21:12 CEST 2008


New submission from romkyns <ws.python at starkov.name>:

See example code attached. A very basic http server responds with an XML
document to any GET request. I think what happens is that the connection
remains open at the end of the request, leading the browser to believe
there's more data to come (and hence not displaying anything).

What's curious is that commenting out the single line "self.dummy =
self" fixes the problem. Also, the problem occurs in 3.0b2 but not in 2.5.2.

To reproduce:

1. Run the example code on 3.0b2
2. Navigate to http://localhost:8123/
   The browser shows "Transferring data" or something similar, until it
times out.
3. Comment out the line "self.dummy = self"
4. Navigate to http://localhost:8123/
   This time it loads instantly.

Repeat with 2.5.2 - both variants work.

I don't know much at all about python internals, but it seems that 1) a
circular reference prevents the request handler from being GC'd and 2)
http.server relies on the request being GC'd to finalise the connection.

----------
components: Library (Lib)
files: breakage.py
messages: 72917
nosy: romkyns
severity: normal
status: open
title: Self-reference in BaseHTTPRequestHandler descendants causes stuck connections
type: behavior
versions: Python 3.0
Added file: http://bugs.python.org/file11448/breakage.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3826>
_______________________________________


More information about the New-bugs-announce mailing list