diff options
| author | hmeland | 2000-02-13 13:32:05 +0000 |
|---|---|---|
| committer | hmeland | 2000-02-13 13:32:05 +0000 |
| commit | 7c01958bf8241af38f13f2b22fcfa803bd0f56a0 (patch) | |
| tree | 530d9c66b60e4ec481886b814dc894ef3dde0b60 | |
| parent | 1d904503e0bdbc787904f332055b5cc7dfeab374 (diff) | |
| download | mailman-7c01958bf8241af38f13f2b22fcfa803bd0f56a0.tar.gz mailman-7c01958bf8241af38f13f2b22fcfa803bd0f56a0.tar.zst mailman-7c01958bf8241af38f13f2b22fcfa803bd0f56a0.zip | |
CloseLogs(): new method, useful to avoid `Too many open files' errors
when iterating over lots of lists.
__del__(): Call CloseLogs() instead of accessing self._log_files
directly.
| -rw-r--r-- | Mailman/MailList.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Mailman/MailList.py b/Mailman/MailList.py index 0205319aa..9d0099653 100644 --- a/Mailman/MailList.py +++ b/Mailman/MailList.py @@ -70,8 +70,7 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin, def __del__(self): try: - for f in self._log_files.values(): - f.close() + self.CloseLogs() except AttributeError: # List didn't get far enough to have _log_files pass @@ -855,6 +854,15 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin, logf.write(msg % args + '\n') logf.flush() + def CloseLogs(self): + """Close all of this list's open log files. + + Useful to avoid 'Too many open files' errors when iterating over + lots of lists.""" + for kind, logger in self._log_files.items(): + del self._log_files[kind] + logger.close() + def CheckVersion(self, stored_state): """Migrate prior version's state to new structure, if changed.""" if (self.data_version >= mm_cfg.DATA_FILE_VERSION and |
