473,408 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 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 1926
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.