code: def addObserver(self, observer):
          
          Observable.addObserver(self, observer)
  
          # If self.startOnDemand is True, the reader monitoring
          # thread only runs when there are observers.
          if self.startOnDemand:
              if 0 < self.countObservers():
                  if not self.rmthread:
                      self.rmthread = ReaderMonitoringThread(
                          self,
                          self.readerProc, self.period)
  
                      # start reader monitoring thread in another thread to
                      # avoid a deadlock; addObserver and notifyObservers called
                      # in the ReaderMonitoringThread run() method are
                      # synchronized
                      try:
                          # Python 3.x
                          import _thread
                          _thread.start_new_thread(self.rmthread.start, ())
                      except:
                          # Python 2.x
                          import thread
                          thread.start_new_thread(self.rmthread.start, ())
          else:
              observer.update(self, (self.rmthread.readers, []))
docs: Add an observer.