07/03/03 23:04:58
>>328
スレッド使えばできるんじゃね?下のコードだとなんか時々終わる時に
エラー出るけど、スレッド詳しい人ならちゃんと書けるはず。
import thread
import time
import os
def change():
open("a.txt", "w").write("a")
def watch():
t1 = None
while 1:
t2 = os.path.getmtime("a.txt")
if t1 is not None and t1 != t2:
print "changed"
t1 = t2
time.sleep(1)
change()
thread.start_new_thread(watch, ())
for _ in xrange(5):
change()
time.sleep(2)