[issue47158] logging.handlers.SysLogHandler doesn't get cleaned up properly on exit if it throws an exception

Grégory Starck report at bugs.python.org
Thu Mar 31 08:31:06 EDT 2022


Grégory Starck <g.starck at gmail.com> added the comment:

Enji : you can use this then:

```
In [6]: class Fixed(logging.handlers.SysLogHandler):
   ...:     def __init__(self, *a, **kw):
   ...:         self.socket = None
   ...:         super().__init__(*a, **kw)
   ...:     def close(self):
   ...:         if self.socket is None:
   ...:             return
   ...:         super().close()
```

that looks to be enough to prevent the issue.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47158>
_______________________________________


More information about the Python-bugs-list mailing list