[Tutor] Should I be thinking of threads for this ?
nick at javacat.f2s.com
Thu Aug 25 21:28:45 CEST 2005
I have the following code taken from the Twisted examples -
from twisted.application import internet
for line in fp.readlines():
from twisted.internet import reactor
s = internet.TimerService(1.0, watch, file(sys.argv))
I find this piece of code amazing and I am keen to put it to use.
If I run './filewatcher.py myfile' it will print out any changes made to
'myfile', very similar to 'tail -f' .
Now if I want to have this program monitor several files at once I could
run './filewatcher.py file1 file2 filex' or './filewatcher.py file1 &
./filewatcher file2 & etc' both with minor modifications to the code,
but I think that could cause performance problems relating to the OS.
So I'm thinking I will need to learn python threads (no bad thing)
instead, but Im hoping that someone could tell me if that seems the best
way to go ?
I will be getting to grips with python threads anyway but I'd appreciate
any input on this.
More information about the Tutor