title: Check for open text file
body: <p>I'm writing a Python application with opens several text files in different threads. I want each thread to make some operations on the file while it is open. When the external text editor closes the file the processing of the corresponding thread should stop. So I need to check on whether the text file is still opened or not.</p>
  
  <pre><code>class MyThread (Thread):
  
  def __init__(self, sf):
      Thread.__init__(self)
      self.sf = sf # sourcefile
  
  def run (self):
      subprocess.Popen([EDITOR, self.sf])
  </code></pre>
  
  <p>The problem now is that subprocess opens the file in the editor and run() terminates. How can I keep the run() open until I close the file externally?</p>