Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > SimpleHTTPRequestHandler handling long lasting requests problem

Reply
Thread Tools

SimpleHTTPRequestHandler handling long lasting requests problem

 
 
Andy Leszczynski
Guest
Posts: n/a
 
      03-10-2005

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()
 
Reply With Quote
 
 
 
 
Andy Leszczynski
Guest
Posts: n/a
 
      03-11-2005
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.
 
Reply With Quote
 
 
 
 
Steve Holden
Guest
Posts: n/a
 
      03-11-2005
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/

 
Reply With Quote
 
Andy Leszczynski
Guest
Posts: n/a
 
      03-14-2005
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.
 
Reply With Quote
 
Andy Leszczynski
Guest
Posts: n/a
 
      03-14-2005
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Having compilation error: no match for call to (const __gnu_cxx::hash<long long int>) (const long long int&) veryhotsausage C++ 1 07-04-2008 05:41 PM
[EJB] Long lasting session bean - how to implement progress indicator? pljosh.mail@gmail.com Java 0 12-13-2006 12:55 AM
Time out problems for long lasting actions Mantas Miliukas ASP .Net Building Controls 2 03-09-2005 04:10 PM
long lasting news server? Mrs Beeble Brock NZ Computing 13 02-01-2005 02:33 AM
Session lasting too long -- Session_End event firing way late !! ?? Steve M ASP .Net 5 07-31-2003 09:44 AM



Advertisments