You can use a threading.Condition object. I usually use this in a 'with' context like this
#from __future__ import with_statement # uncomment if python 2.5
from contextlib import contextmanager
from threading import Condition
my_condition = Condition()
filename = "my_file.txt"
def put_data(self, some_data):
f_out = open(filename, "w")
f_in = open(filename)
data = f_in.read()
You can also use the same technique to work with a file kept open for both reading and writing. The amount of work done when the condition is acquired should be kept as small as possible because the condition.acquire() statement blocks a thread until the condition object is available.