[Tutor] sockets, files, threads

Marilyn Davis marilyn at deliberate.com
Mon Jan 17 04:59:14 CET 2005


On Sat, 15 Jan 2005, Danny Yoo wrote:

> 
> 
> > I have only wrapped my lock around file-descriptor creations.  Should I
> > wrap it around closings too?  Or the whole open -> close transaction?
> > It sounds like error-prone work to do the latter.  What am I missing?
> 
> Hi Marilyn,
> 
> Can you send a link to the source code to the Tutor list?  I'm getting the
> feeling that there's might be a design problem.  Just adding locks
> whenever something doesn't work is not a sustainable way to write a
> multithreaded application.
> 
> We have to see why your file descriptors being are being shared between
> threads.  Is there a reason why you need to share them as global
> resources?

No.  And I don't.  They are often attributes of instantiations of
classes; or they come and go quickly.

Thank you for offering to look at the code.  Start at:

http://www.maildance.com/python/doorman/README

Then, the daemon that creates the threads is:

http://www.maildance.com/python/doorman/py_daemon.py

I'm testing using calls to:

http://www.maildance.com/python/doorman/route_mail.py
http://www.maildance.com/python/doorman/doorman.py

Other modules that open and close file descriptors from there are:

http://www.maildance.com/python/doorman/db.py
http://www.maildance.com/python/doorman/doorman_log.py
http://www.maildance.com/python/doorman/exim.py
http://www.maildance.com/python/doorman/move.py

I'll be grateful for any improvements you suggest.  But, I do know
that some modules aren't well-documented, or are hardly documented at
all yet.  And db.py seems like a mess to me.  But I'm not ready to
straighten it up yet.

But the most important one, py_daemon.py, I hope is very readable.

Still though, I should confess, I am feeling a bit dismal about the
thread situation, especially since searching around for info on
critical code.  The examples I found, before I gave up, were all
trivial.  Also, there is this article:

http://linuxgazette.net/107/pai.html

Which says that the performance is almost the same with threads as
with single-threading.  Boo.

So suddenly, I have no idea why I'm down this road.  We have a huge
performance savings from setting up a daemon that reads a socket.
But, unless something changes our minds soon, I'll rip threading out
of our code.

Still though, I am a teacher too, and a student.  So any thoughts you
have about our code will be treated like the pearls they are.

Thank you again.

Marilyn



> 
> 

-- 




More information about the Tutor mailing list