async def do_rollover(self):
if self.stream:<EOL><INDENT>await self.stream.close()<EOL>self.stream = None<EOL><DEDENT>current_time = int(time.time())<EOL>dst_now = time.localtime(current_time)[-<NUM_LIT:1>]<EOL>t = self.rollover_at - self.interval<EOL>if self.utc:<EOL><INDENT>time_tuple = time.gmtime(t)<EOL><DEDENT>else:<EOL><INDENT>time_tuple = time.localtime(t)<EOL>dst_then = time_tuple[-<NUM_LIT:1>]<EOL>if dst_now != dst_then:<EOL><INDENT>if dst_now:<EOL><INDENT>addend = ONE_HOUR_IN_SECONDS<EOL><DEDENT>else:<EOL><INDENT>addend = -ONE_HOUR_IN_SECONDS<EOL><DEDENT>time_tuple = time.localtime(t + addend)<EOL><DEDENT><DEDENT>destination_file_path = self.rotation_filename(<EOL>self.absolute_file_path<EOL>+ "<STR_LIT:.>"<EOL>+ time.strftime(self.suffix, time_tuple)<EOL>)<EOL>if await self.loop.run_in_executor(<EOL>None, lambda: os.path.exists(destination_file_path)<EOL>):<EOL><INDENT>await self.loop.run_in_executor(<EOL>None, lambda: os.unlink(destination_file_path)<EOL>)<EOL><DEDENT>await self.rotate(self.absolute_file_path, destination_file_path)<EOL>if self.backup_count > <NUM_LIT:0>:<EOL><INDENT>files_to_delete = await self.get_files_to_delete()<EOL>if files_to_delete:<EOL><INDENT>await self._delete_files(files_to_delete)<EOL><DEDENT><DEDENT>await self._init_writer()<EOL>new_rollover_at = self.compute_rollover(current_time)<EOL>while new_rollover_at <= current_time:<EOL><INDENT>new_rollover_at = new_rollover_at + self.interval<EOL><DEDENT>if (<EOL>self.when == RolloverInterval.MIDNIGHT<EOL>or self.when in RolloverInterval.WEEK_DAYS<EOL>) and not self.utc:<EOL><INDENT>dst_at_rollover = time.localtime(new_rollover_at)[-<NUM_LIT:1>]<EOL>if dst_now != dst_at_rollover:<EOL><INDENT>if not dst_now:<EOL><INDENT>addend = -ONE_HOUR_IN_SECONDS<EOL><DEDENT>else:<EOL><INDENT>addend = ONE_HOUR_IN_SECONDS<EOL><DEDENT>new_rollover_at += addend<EOL><DEDENT><DEDENT>self.rollover_at = new_rollover_at<EOL>
do a rollover; in this case, a date/time stamp is appended to the filename
when the rollover happens.  However, you want the file to be named for the
start of the interval, not the current time.  If there is a backup count,
then we have to get a list of matching filenames, sort them and remove
the one with the oldest suffix.