code: def _flush(self):
          
          if not self.enabled:
              return
          try:
              try:
                  self.lock.acquire()
                  self.flush()
              except Exception:
                  self.log.error(traceback.format_exc())
          finally:
              if self.lock.locked():
                  self.lock.release()
docs: Decorator for flushing handlers with an lock, catching exceptions