class_docstr: Handler for logging to a set of files, which switches from one file to the
  next when the current file reaches a certain size. Multiple processes can
  write to the log file concurrently, but this may mean that the file will
  exceed the given size.
class_docstr_tok: ["Handler","for","logging","to","a","set","of","files",",","which","switches","from","one","file","to","the","next","when","the","current","file","reaches","a","certain","size",".","Multiple","processes","can","write","to","the","log","file","concurrently",",","but","this","may","mean","that","the","file","will","exceed","the","given","size","."]
docstr: Do a rollover, as described in __init__().
docstr_tok: ["Do","a","rollover",",","as","described","in","__init__","(",")","."]
code: def doRollover(self):
      """
      Do a rollover, as described in __init__().
      """
      if self.backupCount <= 0:
          # Don't keep any backups, just overwrite the existing backup file
          # Locking doesn't much matter here; since we are overwriting it anyway
          self.stream.close()
          self._openFile("w")
          return
      self.stream.close()
      try:
          # Attempt to rename logfile to tempname:  There is a slight race-condition here, but it seems unavoidable
          tmpname = None
          while not tmpname or os.path.exists(tmpname):
              tmpname = "%s.rotate.%08d" % (
                  self.baseFilename,
                  randint(0, 99999999),
              )
          try:
              # Do a rename test to determine if we can successfully rename the log file
              os.rename(self.baseFilename, tmpname)
          except OSError:
              exc_value = sys.exc_info()[1]
              self._degrade(
                  True,
                  "rename failed.  File in use?  exception=%s",
                  exc_value,
              )
              return
  
          # Q: Is there some way to protect this code from a KeboardInterupt?
          # This isn't necessarily a data loss issue, but it certainly would
          # break the rotation process during my stress testing.
  
          # There is currently no mechanism in place to handle the situation
          # where one of these log files cannot be renamed. (Example, user
          # opens "logfile.3" in notepad)
          for i in range(self.backupCount - 1, 0, -1):
              sfn = "%s.%d" % (self.baseFilename, i)
              dfn = "%s.%d" % (self.baseFilename, i + 1)
              if os.path.exists(sfn):
                  # print "%s -> %s" % (sfn, dfn)
                  if os.path.exists(dfn):
                      os.remove(dfn)
                  os.rename(sfn, dfn)
          dfn = self.baseFilename + ".1"
          if os.path.exists(dfn):
              os.remove(dfn)
          os.rename(tmpname, dfn)
          # print "%s -> %s" % (self.baseFilename, dfn)
          self._degrade(False, "Rotation completed")
      finally:
          self._openFile(self.mode)
  
file_path: nipype/nipype/external/cloghandler.py
imports: import os
  import sys
  from random import randint
  from logging import Handler
  from logging.handlers import BaseRotatingHandler
  from filelock import SoftFileLock
  import logging.handlers
label_desc: Use image node_id 9 for calling the ConcurrentRotatingFileHandler obj's underlying member method code with example usage: obj.doRollover() without return types