[3.12] gh-124653: Relax (again) detection of queue API for logging handlers (GH-124897) (GH-125060)

(cherry picked from commit 7ffe94fb24)
This commit is contained in:
Miss Islington (bot) 2024-10-08 08:24:09 +02:00 committed by GitHub
parent 79b4c9d99a
commit bc237ed9a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 78 additions and 55 deletions

View file

@ -502,7 +502,7 @@ class BaseConfigurator(object):
def _is_queue_like_object(obj):
"""Check that *obj* implements the Queue API."""
if isinstance(obj, queue.Queue):
if isinstance(obj, (queue.Queue, queue.SimpleQueue)):
return True
# defer importing multiprocessing as much as possible
from multiprocessing.queues import Queue as MPQueue
@ -519,13 +519,13 @@ def _is_queue_like_object(obj):
# Ideally, we would have wanted to simply use strict type checking
# instead of a protocol-based type checking since the latter does
# not check the method signatures.
queue_interface = [
'empty', 'full', 'get', 'get_nowait',
'put', 'put_nowait', 'join', 'qsize',
'task_done',
]
#
# Note that only 'put_nowait' and 'get' are required by the logging
# queue handler and queue listener (see gh-124653) and that other
# methods are either optional or unused.
minimal_queue_interface = ['put_nowait', 'get']
return all(callable(getattr(obj, method, None))
for method in queue_interface)
for method in minimal_queue_interface)
class DictConfigurator(BaseConfigurator):
"""