code: def enable_thread_safety(self):
          
          if self.threadsafe:
              return                        # Already done!
          if self._running.isSet():
              raise RuntimeError('Cannot enable thread safety after start')
  
          def _getattr(obj, name):
              # use 'is True' so mock objects don't return true for everything
              return getattr(obj, name, False) is True
  
          for name in dir(self):
              try:
                  meth = getattr(self, name)
              except AttributeError:
                  # Subclasses may have computed attributes that don't work
                  # before they are started, so let's ignore those
                  pass
              if not callable(meth):
                  continue
              make_threadsafe = _getattr(meth, 'make_threadsafe')
              make_threadsafe_blocking = _getattr(meth, 'make_threadsafe_blocking')
  
              if make_threadsafe:
                  assert not make_threadsafe_blocking
                  meth = self._make_threadsafe(meth)
                  setattr(self, name, meth)
              elif make_threadsafe_blocking:
                  meth = self._make_threadsafe_blocking(meth)
                  setattr(self, name, meth)
  
          self._threadsafe = True
docs: Enable thread-safety features.
  
          Must be called before start().