Message374859
The `logging.handlers.MemoryHandler.flush()` method acquire the lock even if target has not been set, and the method is a noop:
```
def flush(self):
# (Docstring skipped)
self.acquire()
try:
if self.target:
for record in self.buffer:
self.target.handle(record)
self.buffer..clear()
finally:
self.release()
```
An optimized version would re-arrrange the nesting to avoid the locking:
```
def flush(self):
# (Docstring skipped)
if self.target:
self.acquire()
try:
for record in self.buffer:
self.target.handle(record)
self.buffer.clear()
finally:
self.release()
```
- There is no use-case, beyond the expected performance gain.
- Without having searched, i would deem highly improbable the existence of code in the std-library or 3rdp code that depends on the current noop-locking when `flush()` is called. |
|
Date |
User |
Action |
Args |
2020-08-05 06:06:14 | ankostis | set | recipients:
+ ankostis, vinay.sajip, penlect |
2020-08-05 06:06:13 | ankostis | set | messageid: <1596607573.95.0.247308930011.issue41483@roundup.psfhosted.org> |
2020-08-05 06:06:13 | ankostis | link | issue41483 messages |
2020-08-05 06:06:13 | ankostis | create | |
|