[cse491] how do I test threading?

C. Titus Brown ctb at msu.edu
Wed Sep 24 17:24:32 PDT 2008


On Wed, Sep 24, 2008 at 08:12:16PM -0400, Abhinav Parvataneni wrote:
->   The attached is my code for HW4.  I based it off the webserve you provided
-> us.  I also have the threading done I belive.  I was wondering how I would
-> test if the threading works or not...I tried using multiple telnet
-> connections, but assert statements get me.  I'm not sure what I am to do :\
-> Thanks!

Hey Abe,

hmm, let's see...  I think the easiest way to test for correct threading
is to put in 'time.sleep(n)' statements, so that each connection takes a
long time to be handled.  Then open up multiple connections to the Web
server and make sure that they're handled properly.  The only trick here
is to distinguish between connections that are waiting to be returned
from 'accept' and connections that are in the 'time.sleep' call; you
could put in some print statements to differentiate between the two.

You could also try setting 'listen' to 1 and opening up four or five
connections at once, after you put in a 'time.sleep(5)'.  That will make
sure that the connections are actually being 'accept'ed and not simply
queued up waiting for the 'accept' call to return them.

--titus
-- 
C. Titus Brown, ctb at msu.edu



More information about the cse491-fall-2008 mailing list