473,395 Members | 1,343 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,395 software developers and data experts.

SimpleHTTPRequestHandler handling long lasting requests problem


I need a HTTP server handling long lasting requests e.g. 10-30 seconds.
Below is a pice of the code. In order to make the server reponsive while
handling othere requests I use SocketServer.ThreadingMixIn.

However the problem is the it does not work out. I checked thet a new
thread is created for each new connection new, but the main loop seems
to be frozen until the prevoius handling ends.

What could go wrong?

Thanks, Andy

* * *

import os
import time
import BaseHTTPServer
import SocketServer
import threading
import sys

class
SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRe questHandler):
def do_GET(self):
response="aaaaaaaaaaaaaaaa"+str(time.time())
self.send_response(200)
self.send_header("Content-type",'text/plain')

self.send_header("Content-Length",len(response))
self.end_headers()
time.sleep(10) #simulation of the processing
self.wfile.write(response)

def do_POST(self):
self.do_GET()

class
myWebServer(SocketServer.ThreadingMixIn,BaseHTTPSe rver.HTTPServer):
pass

if __name__ == '__main__':
server_address = ('',80)
httpd=myWebServer(server_address,SimpleHTTPRequest Handler)
sa=httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1],"..."
httpd.serve_forever()
Jul 18 '05 #1
4 3293
Sorry for questioning Python :-) - it turned out that this is a problem
with Mozilla. For some reason it holds up with opening second connection
to given host until the previous one is completed. Interestingly enough,
IE works better with Python multi threaded server in that regard.

Thx, A.
Jul 18 '05 #2
Andy Leszczynski wrote:
Sorry for questioning Python :-) - it turned out that this is a problem
with Mozilla. For some reason it holds up with opening second connection
to given host until the previous one is completed. Interestingly enough,
IE works better with Python multi threaded server in that regard.

Thx, A.


Try switching keepalives off, or falling back to HTTP 1.0 - ironically
it may be the attempt to use the same connection for both pieces of
content that holds things up.

regards
Steve
--
Steve Holden +1 703 861 4237 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/

Jul 18 '05 #3
Steve Holden wrote:
Andy Leszczynski wrote:
Sorry for questioning Python :-) - it turned out that this is a
problem with Mozilla. For some reason it holds up with opening second
connection to given host until the previous one is completed.
Interestingly enough, IE works better with Python multi threaded
server in that regard.

Thx, A.

Try switching keepalives off, or falling back to HTTP 1.0 - ironically
it may be the attempt to use the same connection for both pieces of
content that holds things up.

regards
Steve


I tested it before and it did not work either. Have to try HTTP 1.0 thouh.

Thanks, A.
Jul 18 '05 #4
Steve Holden wrote:
Andy Leszczynski wrote:
Sorry for questioning Python :-) - it turned out that this is a
problem with Mozilla. For some reason it holds up with opening second
connection to given host until the previous one is completed.
Interestingly enough, IE works better with Python multi threaded
server in that regard.

Thx, A.

Try switching keepalives off, or falling back to HTTP 1.0 - ironically
it may be the attempt to use the same connection for both pieces of
content that holds things up.

regards
Steve


I tested it before and it did not work either. Have to try HTTP 1.0 thouh.

Thanks, A.
Jul 18 '05 #5

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

Similar topics

1
by: Marian Horniak | last post by:
hello to everyone, please can you give me a link to example with request handling on IIS ver 5 and 6 ? Main idea is : work with request from all clients complexly . (e.g. set priority, canceling...
5
by: Steve M | last post by:
Why are my sessions lasting so long? I have them set to 20 minute timeout in config file? The Session_End event is getting called an hour or more sometimes--well after the user has stopped...
4
by: Ryan | last post by:
I am hoping to get some ideas on how to handle a case when an application gets too many requests for an application... I would like to handle the case well... (1) is the answer in using the...
2
by: Seth | last post by:
Ok, here is my setup. I have a fully functioning HTTP Handler implemented. The handler is supposed to handle every single request that comes in to a particular virtual directory. Thus, in IIS, I...
33
by: Anthony England | last post by:
I am considering general error handling routines and have written a sample function to look up an ID in a table. The function returns True if it can find the ID and create a recordset based on...
0
by: ob | last post by:
The situation I have is that I have a long running process (that takes 15 min to process) kicked off from an ASP.NET page. I launch a thread and kick of the process and return instantly. I store...
3
by: lai_waiman | last post by:
Dear All, I have problems on doing some long lasting job in a web services. Let me first provide some background information first. I have a ASP.NET web page, which will call another Web...
0
by: =?Utf-8?B?QmFjaA==?= | last post by:
Hi, I have a ASP.NET 2.0 web service, which runs beautifully when hosted in the development server of VS2005 (out side of IIS) but crashes when hosted inside IIS 5.1 or IIS 6.0 when it takes...
1
by: Christoph Boget | last post by:
I'm experiencing a very odd problem and it's happening only in IE6. IE7, Safari, Opera and Firefox are all working properly. What's happening is that I'm using XHR request responses to update the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.