title: Generating multiple observers with Python watchdog
body: <p>I currently have a basic functioning script that monitors a single directory and all sub-directories below for changes and passes the output to the LoggingEventHandler.</p>
  
  <p>I now want to expand my script to monitor 3 separate locations but I simply can't grasp how to generate multiple Observers to watch each of my designated paths.</p>
  
  <p>I attempted something along the lines of the following:</p>
  
  <pre><code>import time
  import thread
  import threading
  from watchdog.observers import Observer
  from watchdog.events import LoggingEventHandler
  
  event_handler = LoggingEventHandler()
  observer = Observer()
  
  paths = ["C:\dir1", "C:\dir2", "C:\dir3"]
  
  for i in paths:
      targetPath = str(i)
      observer.schedule(event_handler, targetPath, recursive=True)
      observer.start_new_thread()
  </code></pre>
  
  <p>Unfortunately I received an error indicating that observer doesn't have an attribute 'start_new_thread'</p>
  
  <p>There is no example within the documentation that shows more than a single observer monitoring a directory. I have no experience of dealing with threads and I'm not even sure if I am on the right track.</p>
  
  <p>Should I be creating a new instance of the observer class for each path instead? Or is there some method of feeding a single instance of the Observer class, multiple paths?</p>
  
  <p>Apologies if there is a glaringly obvious answer. I am sure this is all completely wrong now, I am just too tired to understand.</p>
  
  <p>ADDITIONAL:</p>
  
  <p>Thanks to @FogleBird I have corrected the thread start issue but I am still stuck with only a single instance rather than three separate observers watching the different paths. My altered code now looks like:</p>
  
  <pre><code>threads = []
  
  for i in paths:
      targetPath = str(i)
      observer.schedule(event_handler, targetPath, recursive=True)
      threads.append(observer)
  
  observer.start()
  print threads
  </code></pre>
  
  <p>This returns three ObservedWatch objects but they all have the same details:</p>
  
  <pre><code>[&lt;Observer(Thread-1, started daemon 1548)&gt;, &lt;Observer(Thread-1, started daemon 1548)&gt;, &lt;Observer(Thread-1, started daemon 1548)&gt;]
  </code></pre>
  
  <p>Still looks completely wrong, any more help would be great. I am struggling to grasp this concept.</p>
  
  <p>ADDITIONAL 2:</p>
  
  <p>I have continued mucking about with the code and I now have something that appears to be functional:</p>
  
  <pre><code>event_handler = LoggingEventHandler()
  N2watch = Observer()
  threads = []
  
  for i in paths:
      targetPath = str(i)
      N2watch.schedule(event_handler, targetPath, recursive=True)
      threads.append(N2watch)
  
  N2watch.start()
  
  try:
      while True:
              time.sleep(1)
  except KeyboardInterrupt:
      N2watch.stop()
  N2watch.join()
  </code></pre>
  
  <p>From what I can gather from an initial run the output appeared to pickup changes in all three of the path names specified in my list but I will need to write some test code to check.</p>
  
  <p>I am still not certain how this is behaving so any further comments would be great.</p>
  
  <p>Cheers.</p>
  
  <p>ADDITIONAL 3:</p>
  
  <p>I marked FogleBird's answer as the best because it was simply the only one and did highlight issues with my initial code.</p>
  
  <p>My previous edit included fully working code to monitor multiple locations and appears to be functioning correctly at present.</p>