From 656ead6c26cb2454f623f99b522c05fea90aa2ba Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Sun, 11 Oct 2020 00:38:49 +0000 Subject: [PATCH] Delay closing files on channels removed from the config This introduces an up to 10 second delay if a SIGINT is received just after changing the config. I can't be bothered to integrate this with Storage.run and overly complicate things. --- irclog.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/irclog.py b/irclog.py index 8913956..c323d76 100644 --- a/irclog.py +++ b/irclog.py @@ -638,6 +638,11 @@ class Storage: self.config = config self.paths = {channel['ircchannel']: channel['path'] for channel in self.config['channels'].values()} + # Since the PART messages will still arrive for the removed channels, only close those files after a little while. + asyncio.create_task(self.delayed_close_files(channelsRemoved)) + + async def delayed_close_files(self, channelsRemoved): + await asyncio.sleep(10) for channel in channelsRemoved: if channel in self.files: self.logger.debug(f'Closing file for {channel!r}')