I have a thread that is off reading things some of which will get written into a file while another UI thread manages input from a user.

The reader-thread and the UI-thread will both want to write stuff to the same output file. What first comes to mind is that there may be write collisions, ie both trying to write at the same time.

Should I do something like:


if busyFlag:
  while busyFlag:
     sleep(10)
else:
  busyFlag = True
  {write stuff to file}
  busyFlag = False


in both threads? Is there some other approach that would be more appropriate?

Thanks in advance for your advice
- Ross.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to