mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-22 03:41:28 +08:00
Allow passing multiprocessing.Queues to QueueListener/QueueHandler (#10169)
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import logging.handlers
|
||||
import multiprocessing
|
||||
import queue
|
||||
from typing import Any
|
||||
|
||||
# This pattern comes from the logging docs, and should therefore pass a type checker
|
||||
@@ -16,3 +19,12 @@ def record_factory(*args: Any, **kwargs: Any) -> logging.LogRecord:
|
||||
|
||||
|
||||
logging.setLogRecordFactory(record_factory)
|
||||
|
||||
# The logging docs say that QueueHandler and QueueListener can take "any queue-like object"
|
||||
# We test that here (regression test for #10168)
|
||||
logging.handlers.QueueHandler(queue.Queue())
|
||||
logging.handlers.QueueHandler(queue.SimpleQueue())
|
||||
logging.handlers.QueueHandler(multiprocessing.Queue())
|
||||
logging.handlers.QueueListener(queue.Queue())
|
||||
logging.handlers.QueueListener(queue.SimpleQueue())
|
||||
logging.handlers.QueueListener(multiprocessing.Queue())
|
||||
|
||||
Reference in New Issue
Block a user