(beginner) question on threads...

Joseph Andrew Knapka jknapka at earthlink.net
Sun Sep 2 21:14:37 EDT 2001


Fred Pacquier wrote:
> 
> Skip Montanaro <skip at pobox.com> said :
> 
> > I think you can just create a suitable subclass of
> > SocketServer.TCPServer. In my XML-RPC server, I did:
> >
> >     class GenericServer(SocketServer.ThreadingMixIn,
> >     SocketServer.TCPServer):
> >         """generic XML-RPC server class"""
> >         ...
> > Each request to my server is handled in a separate thread.
> 
> By Jove, it works ! Python will never cease to amaze me...
> I probably got more than I bargained for, though : now I need to understand
> _why_ it just works -- and probably have to delve into that "mixin" stuff I
> was saving for later too :-)

Had a similar experience recently. Class A had some code that would be
very handy in class B. I thought the code in question would probably
work unchanged, since A and B already contained all the data attributes
needed. So I pulled the method in question (only -- the data on which it
depended stayed put) out into a separate mixin class, had A and B
inherit
the new class, and Poof! It worked immediately. I used to be a
static-analysis zealot, but I am gaining a really strong appreciation
for Python's wonderful dynamicism.

> Thanks for the tip, Skip ! (hey, that sounds like an old Paul Simon song :)

"Just say no to C, Lee,
 And get yourself free..."

Cheers,

-- 
# Joe Knapka
# "You know how many remote castles there are along the
#  gorges? You can't MOVE for remote castles!" - Lu Tze re. Uberwald
# Linux MM docs:
http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html



More information about the Python-list mailing list