Browse Source

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.
master
JustAnotherArchivist 3 years ago
parent
commit
656ead6c26
1 changed files with 5 additions and 0 deletions
  1. +5
    -0
      irclog.py

+ 5
- 0
irclog.py View File

@@ -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}')


Loading…
Cancel
Save