Issue 32934: logging.handlers.BufferingHandler capacity is unclearly specified (original) (raw)

Issue32934

Created on 2018-02-24 10:24 by enrico, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 14498 merged vinay.sajip,2019-07-01 06:44
PR 14507 merged miss-islington,2019-07-01 11:42
PR 14508 merged miss-islington,2019-07-01 11:42
Messages (6)
msg312709 - (view) Author: Enrico Zini (enrico) Date: 2018-02-24 10:24
BufferingHandler's documentatio says "Initializes the handler with a buffer of the specified capacity." but it does not specify what capacity means. One would assume the intention is to give a bound to memory usage, and that capacity is bytes. Looking at the source instead, the check is: return (len(self.buffer) >= self.capacity) and self.buffer is initialised with an empty list, so capacity is a number of lines, which cannot be used to constrain memory usage, and for which I struggle to see a use case. I believe that the current behaviour is counterintuitive enough to deserve, if not changing, at least documenting
msg346277 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2019-06-22 12:46
Python isn't a low-level language, and there isn't *in general* a particular intention "to give a bound to memory usage". When using "buffer" in a general sense, rather than a buffer object (which is more akin to a byte-array), it's usually understood to mean a Python list (used as an array) and the capacity refers to the number of elements. You may struggle to see a use case for specifying a buffer capacity as a number of elements rather than a byte size, but that doesn't mean that such use cases don't exist. Are you perhaps using MicroPython in a constrained-memory environment? In the 17 years that this code has been in Python, it's the first time AFAIK that anyone has raised the term "capacity" as potentially confusing, so I don't think such confusion is common. However, I'll be happy to update the documentation to clarify that "capacity" means "number of records buffered".
msg346320 - (view) Author: Enrico Zini (enrico) Date: 2019-06-23 13:16
Thanks! Clarifying "number of records buffered" would perfectly solve the problem for me.
msg347005 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2019-07-01 11:41
New changeset 84de34e39eb9e49b2ae691c6f67df8d7da3561de by Vinay Sajip in branch 'master': bpo-32934: Clarified meaning of 'capacity' for BufferingHandler and MemoryHandler. (GH-14498) https://github.com/python/cpython/commit/84de34e39eb9e49b2ae691c6f67df8d7da3561de
msg347007 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2019-07-01 12:12
New changeset 471d785dc759eb2e9c06f077f323cf136d32506b by Vinay Sajip (Miss Islington (bot)) in branch '3.7': bpo-32934: Clarified meaning of 'capacity' for BufferingHandler and MemoryHandler. (GH-14498) (GH-14508) https://github.com/python/cpython/commit/471d785dc759eb2e9c06f077f323cf136d32506b
msg347008 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2019-07-01 12:12
New changeset 3db5c5c7630af92336a8c0a269e05607cd68f9e7 by Vinay Sajip (Miss Islington (bot)) in branch '3.8': bpo-32934: Clarified meaning of 'capacity' for BufferingHandler and MemoryHandler. (GH-14498) (GH-14507) https://github.com/python/cpython/commit/3db5c5c7630af92336a8c0a269e05607cd68f9e7
History
Date User Action Args
2022-04-11 14:58:58 admin set github: 77115
2019-07-01 12:12:59 vinay.sajip set status: open -> closedresolution: fixedstage: patch review -> resolved
2019-07-01 12:12:13 vinay.sajip set messages: +
2019-07-01 12:12:02 vinay.sajip set messages: +
2019-07-01 11:42:16 miss-islington set pull_requests: + <pull%5Frequest14324>
2019-07-01 11:42:08 miss-islington set pull_requests: + <pull%5Frequest14323>
2019-07-01 11:41:25 vinay.sajip set messages: +
2019-07-01 06:44:28 vinay.sajip set keywords: + patchstage: needs patch -> patch reviewpull_requests: + <pull%5Frequest14314>
2019-06-23 13:16:48 enrico set messages: +
2019-06-22 12:46:26 vinay.sajip set messages: + assignee: vinay.sajipcomponents: + Documentation, - Library (Lib)type: behavior -> stage: needs patch
2019-06-22 04:45:10 xtreak set nosy: + vinay.sajiptype: behaviorversions: + Python 3.7, Python 3.8, Python 3.9, - Python 3.6
2018-02-24 10:24:49 enrico create