[Tutor] The thread module

Bernard Lebel python at bernardlebel.com
Sat Sep 4 17:36:21 CEST 2004


It is my first ever attempt at managing threads. And I must admit that I am
absolutely lost! I don't know if I'm using the right approach at all for
what I'm after, so if you have any suggestion, do not hesitate!

What I'm looking for:
I launch a command line shell, import a script, and the script runs forever.
The watches two main things:
1- The accessibility of two shared locations on the network, so if one of
them goes down (or both), an email is sent to various people. When one
server goes down, it is no longer checked. When both server go down, none
are checked. A check is performed every 5 minutes.
2- The remaining space on several network volumes, and if one goes under
5Gb, again, an email is sent. The check is performed no matter what, every

Currently I have two scripts that do the job very well.

Now the problem is that I want to consolidate them into one, so I don't have
two python shell running, but one.
I figured that using child threads would be a good way to manage this,
because each thread could manage task. Basically I am looking at doing two
parallel loops.

So I've messed a little bit with the thread module, and have read the pdf
tutorial from Norman Matloff, but I'm still confused about the whole thing.
Anyone can recommend tutorial or ressources for this? Or even a different
approach for the problem?

Thanks in advance

More information about the Tutor mailing list