MCPcopy Index your code
hub / github.com/python/cpython / _is_queue_like_object

Function _is_queue_like_object

Lib/logging/config.py:500–525  ·  view source on GitHub ↗

Check that *obj* implements the Queue API.

(obj)

Source from the content-addressed store, hash-verified

498 return value
499
500def _is_queue_like_object(obj):
501 """Check that *obj* implements the Queue API."""
502 if isinstance(obj, (queue.Queue, queue.SimpleQueue)):
503 return True
504 # defer importing multiprocessing as much as possible
505 from multiprocessing.queues import Queue as MPQueue
506 if isinstance(obj, MPQueue):
507 return True
508 # Depending on the multiprocessing start context, we cannot create
509 # a multiprocessing.managers.BaseManager instance 'mm' to get the
510 # runtime type of mm.Queue() or mm.JoinableQueue() (see gh-119819).
511 #
512 # Since we only need an object implementing the Queue API, we only
513 # do a protocol check, but we do not use typing.runtime_checkable()
514 # and typing.Protocol to reduce import time (see gh-121723).
515 #
516 # Ideally, we would have wanted to simply use strict type checking
517 # instead of a protocol-based type checking since the latter does
518 # not check the method signatures.
519 #
520 # Note that only 'put_nowait' and 'get' are required by the logging
521 # queue handler and queue listener (see gh-124653) and that other
522 # methods are either optional or unused.
523 minimal_queue_interface = ['put_nowait', 'get']
524 return all(callable(getattr(obj, method, None))
525 for method in minimal_queue_interface)
526
527class DictConfigurator(BaseConfigurator):
528 """

Callers 1

configure_handlerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…