mirror of
https://github.com/python/cpython.git
synced 2025-08-09 19:38:42 +00:00
[3.12] gh-120868: Fix breaking change in logging.config
when using QueueHandler
(GH-120872) (GH-121077)
(cherry picked from commit 7d9c68513d
)
This commit is contained in:
parent
8ea6cc14a5
commit
b31f7e2e90
3 changed files with 82 additions and 17 deletions
|
@ -60,6 +60,7 @@ import warnings
|
|||
import weakref
|
||||
|
||||
from http.server import HTTPServer, BaseHTTPRequestHandler
|
||||
from unittest.mock import patch
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
from socketserver import (ThreadingUDPServer, DatagramRequestHandler,
|
||||
ThreadingTCPServer, StreamRequestHandler)
|
||||
|
@ -3895,6 +3896,50 @@ class ConfigDictTest(BaseTest):
|
|||
msg = str(ctx.exception)
|
||||
self.assertEqual(msg, "Unable to configure handler 'ah'")
|
||||
|
||||
@threading_helper.requires_working_threading()
|
||||
@support.requires_subprocess()
|
||||
@patch("multiprocessing.Manager")
|
||||
def test_config_queue_handler_does_not_create_multiprocessing_manager(self, manager):
|
||||
# gh-120868
|
||||
|
||||
from multiprocessing import Queue as MQ
|
||||
|
||||
q1 = {"()": "queue.Queue", "maxsize": -1}
|
||||
q2 = MQ()
|
||||
q3 = queue.Queue()
|
||||
|
||||
for qspec in (q1, q2, q3):
|
||||
self.apply_config(
|
||||
{
|
||||
"version": 1,
|
||||
"handlers": {
|
||||
"queue_listener": {
|
||||
"class": "logging.handlers.QueueHandler",
|
||||
"queue": qspec,
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
manager.assert_not_called()
|
||||
|
||||
@patch("multiprocessing.Manager")
|
||||
def test_config_queue_handler_invalid_config_does_not_create_multiprocessing_manager(self, manager):
|
||||
# gh-120868
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
self.apply_config(
|
||||
{
|
||||
"version": 1,
|
||||
"handlers": {
|
||||
"queue_listener": {
|
||||
"class": "logging.handlers.QueueHandler",
|
||||
"queue": object(),
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
manager.assert_not_called()
|
||||
|
||||
@support.requires_subprocess()
|
||||
def test_multiprocessing_queues(self):
|
||||
# See gh-119819
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue