def acquire(self):
        """ Acquire thread and file locks.  Re-opening log for 'degraded' mode.
        """
        self._console_log("In acquire", stack=True)

        # handle thread lock
        super(ConcurrentRotatingFileHandler, self).acquire()

        # noinspection PyBroadException
        try:
            self._open_lockfile()
        except Exception:
            self.handleError(NullLogRecord())

        # Issue a file lock.  (This is inefficient for multiple active threads
        # within a single process. But if you're worried about high-performance,
        # you probably aren't using this log handler.)
        self._stream_lock_count += 1
        self._console_log(">> stream_lock_count = %s" % (self._stream_lock_count,))
        if self._stream_lock_count == 1:
            self._console_log(">Getting lock for %s" % (self.stream_lock,), stack=True)

            lock(self.stream_lock, LOCK_EX)
            self.stream = self._open()
Exemplo n.º 2
0
 def _do_lock(self):
     if self.stream_lock:
         lock(self.stream_lock, LOCK_EX)
     else:
         self._console_log("No self.stream_lock to lock", stack=True)