473,473 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

HTTPServer and ThreadingMixIn

Hello,

I am having trouble getting the ThreadingMixIn to do what I want.
Looking over the docs (and some old code I wrote which successfully
does what I want), I arrived at the following:

import time
import SocketServer
import BaseHTTPServer

class TheServer(SocketServer.ThreadingMixIn,
BaseHTTPServer.HTTPServer):
pass

class TheHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
print "sleeping..."
time.sleep(10)
print "awake!"

if __name__ == "__main__":
theServer = TheServer(('', 8083), TheHandler)
theServer.serve_forever()

I would like this server to print "sleeping..." when someone make a
request, waits 10 seconds, then prints "awake!" This works, but it
does not exhibit threading behavior; i.e. it handles the requests in
sequential order:
sleeping...
awake!
sleeping...
awake!

Is there some problem with using the time.sleep() method? Or have I
done something else wrong? Sorry for asking such a simple question,
but it seems I am unable to pinpoint my error.

Thanks.

--Rob

May 15 '06 #1
0 1911

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

Similar topics

0
by: WmGill | last post by:
I'm new to Python, and am dabbling with it to replace a lot of scattered scripts & programs. One thing I want to try is an HTTPserver like in the pydocgui module. This way I can use html to...
0
by: Will Stuyvesant | last post by:
I have a CGI server written in Python, useful for offline CGI testing. One of my CGI scripts ends with: print 'Location: http://myresourcelocation' print But this does not work with the...
1
by: Erik Johnson | last post by:
Hi, I am trying to spawn a daemon type program to go off on its own and do some work (asynchoronously) from within an HTTPServer, but I am running into a problem where the web browser (actually...
2
by: Tortelini | last post by:
I am making custom web server using HTTPServer and want to be able to access it simultaneously from different computers. To achieve multithreading, I have been experimenting with ThreadingMixIn...
4
by: Andy Leszczynski | last post by:
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...
0
by: Frank Abel | last post by:
Hi all! I will build a HTTPServer and dislike that one request is handled at a time (synchronous). So I write: class MyHTTPServer(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer): .......
1
by: Alvin A. Delagon | last post by:
I'm a simple python webserver based on CGIHTTPServer module: import CGIHTTPServer import BaseHTTPServer import SocketServer import sys import SQL,network from config import * class
0
by: =?ISO-8859-1?Q?Gerhard_H=E4ring?= | last post by:
In a recent experiment I've done this: from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler from wsgiref.simple_server import make_server, demo_app from SocketServer import...
0
by: =?UTF-8?B?R2VyaGFyZCBIw6RyaW5n?= | last post by:
Gabriel Genellina wrote: Yes, it does! I was totally on the wrong track. Of course the ThreadingMixin can also be "mixed in" later in the chain. -- Gerhard
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
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...
1
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.