472,371 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 software developers and data experts.

Stuck connection in Python 3.0b2 http.server

Hi All

I've encountered a weird issue when migrating a web server to Python 3
- the browser would wait forever without showing a page, displaying
"Transferring data" in the status bar. I tracked it down to a
reference cycle in my BaseHTTPRequestHandler descendant - one of the
attributes stored a dict of methods. Removing the cycle made the
problem go away.

In Python 2.5.2 the code works fine either way.

Here's a minimal example which runs in both 2.5 and 3.0 - to see stuck
connections run as-is in 3.0 and navigate to http://localhost:8123; to
fix this comment out "self.dummy = self" (alternatively reset
self.dummy = None at the end of the __init__ method).

Am I doing it wrong, or is this a bug?
try:
import http.server
httpmodule = http.server
except:
import BaseHTTPServer
httpmodule = BaseHTTPServer

class BreakageRequest(httpmodule.BaseHTTPRequestHandler) :
def __init__(self, request, client_address, server):
self.dummy = self # COMMENT THIS OUT to see the connection
become unstuck
httpmodule.BaseHTTPRequestHandler.__init__(self, request,
client_address, server)
def do_GET(self):
self.send_response(200)
self.send_header("Content-Type", "application/xml")
self.end_headers()
self.wfile.write("<is_it_stuck/>".encode('utf-8'))

srv = httpmodule.HTTPServer(('', 8123), BreakageRequest)
srv.serve_forever()
Sep 14 '08 #1
1 1836
rs387 wrote:
I've encountered a weird issue when migrating a web server to Python 3
- the browser would wait forever without showing a page, displaying
"Transferring data" in the status bar. I tracked it down to a
reference cycle in my BaseHTTPRequestHandler descendant - one of the
attributes stored a dict of methods. Removing the cycle made the
problem go away.

In Python 2.5.2 the code works fine either way.

Here's a minimal example which runs in both 2.5 and 3.0 - to see stuck
connections run as-is in 3.0 and navigate to http://localhost:8123; to
fix this comment out "self.dummy = self" (alternatively reset
self.dummy = None at the end of the __init__ method).

Am I doing it wrong, or is this a bug?
it's weird enough to deserve an issue over at http://bugs.python.org/,
at least.

it'd probably be a good idea to test this on 2.6rc as well.

</F>

Sep 14 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Fortepianissimo | last post by:
Here is the situation: I want my server started up upon connection. When the first connection comes in, the server is not running. The client realizes the fact, and then starts up the server and...
4
by: Fuzzyman | last post by:
In a nutshell - the question I'm asking is, how do I make a socket conenction go via a proxy server ? All our internet traffic has to go through a proxy-server at location 'dav-serv:8080' and I...
2
by: Angel | last post by:
I'm in the process of working on a Windows payroll application but I wanted some help on what design pattern I should use. For example, if my main Form needs all active employees in the DB, I'd...
8
by: Morgan Cheng | last post by:
I happens to surf to http://www.codeproject.com/cs/internet/Crawler.asp, which claims that WebRequest.GetResponse() will block other thread calling this function until WebResponse.Close() is...
2
by: seb | last post by:
Hi, this simple server (time protocol) does not respond after a few hours, even when it is restarted. The behaviour looks to me like a firewall blocking but I have desabled the firewall. Using...
0
by: Sugrue, Sean | last post by:
Is this the right email list to be on for asking rather elementary python questions? If not do you have a suggestion Sean -----Original Message----- From:...
1
by: getafixx | last post by:
Hello everyone, We have a linux server (Fedora core 7, default install, firewall turned off) and a bunch of windows XP machines on network/domain. All machines are visible and I can get to both...
5
by: chrispoliquin | last post by:
Hi, I have a small Python script to fetch some pages from the internet. There are a lot of pages and I am looping through them and then downloading the page using urlretrieve() in the urllib...
2
by: Roopesh | last post by:
Hi, I am using poplib's retr() to fetch mails from my gmail account. It works fine, in some cases it gets stuck inside the retr() method and does not come out. From the logs I could find that...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.