[cse491] [marsh253 at msu.edu: Re: how do I test threading?]

C. Titus Brown ctb at msu.edu
Thu Sep 25 22:48:51 PDT 2008


----- Forwarded message from Taylor Marshall <marsh253 at msu.edu> -----

X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on teckla.idyll.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DNS_FROM_RFC_POST 
	autolearn=no version=3.1.7
From: Taylor Marshall <marsh253 at msu.edu>
To: titus at idyll.org
Subject: Re: [cse491] how do I test threading?
X-Google-Sender-Auth: 6a8094e6bfc8d10d

Hi Titus,

I came up with what is a pretty good (I think so, anyway) method for
testing this.   I know it's late night and it's due tomorrow, but I
figured it could possibly help someone out.

First, I opened a bunch of tabs in firefox that had addresses like
this (from left to right)

http://localhost:5555/threading/test?number=1
http://localhost:5555/threading/test?number=2
http://localhost:5555/threading/test?number=3
...et cetera

Then I did a "bookmark all tabs".

In my code I put a print statement by the 'accept' call and by the
call to send a response.

Right before sending the response print statement, I put:
time.sleep(random.random() * 5.0) .   This will make each thread wait
a random duration between 0 and 5 seconds.

When I was ready to test, I opened my bookmarks, went to the folder
that contained all my test links, and clicked "open all in tabs".
Firefox will send the requests from left to right.

This way you can be sure your connections are all being accepted, and
you can see the responses being sent out of order.

-Taylor


On Wed, Sep 24, 2008 at 8:24 PM, C. Titus Brown <ctb at msu.edu> wrote:
> 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
>
> _______________________________________________
> cse491-fall-2008 mailing list
> cse491-fall-2008 at lists.idyll.org
> http://lists.idyll.org/listinfo/cse491-fall-2008
>

----- End forwarded message -----

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



More information about the cse491-fall-2008 mailing list