Skip to content

Commit

Permalink
pythongh-119819: Update logging configuration to support joinable mul…
Browse files Browse the repository at this point in the history
…tiproc… (pythonGH-120090)

pythongh-119819: Update logging configuration to support joinable multiprocessing manager queues.
  • Loading branch information
vsajip authored Jun 5, 2024
1 parent b6b0dcb commit 983efcf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Lib/logging/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,10 @@ def configure_handler(self, config):
from multiprocessing.queues import Queue as MPQueue
from multiprocessing import Manager as MM
proxy_queue = MM().Queue()
proxy_joinable_queue = MM().JoinableQueue()
qspec = config['queue']
if not isinstance(qspec, (queue.Queue, MPQueue, type(proxy_queue))):
if not isinstance(qspec, (queue.Queue, MPQueue,
type(proxy_queue), type(proxy_joinable_queue))):
if isinstance(qspec, str):
q = self.resolve(qspec)
if not callable(q):
Expand Down
8 changes: 6 additions & 2 deletions Lib/test/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -3928,12 +3928,16 @@ def test_config_queue_handler(self):

def test_multiprocessing_queues(self):
# See gh-119819
import_helper.import_module('_multiprocessing') # will skip test if it's not available

# will skip test if it's not available
import_helper.import_module('_multiprocessing')

cd = copy.deepcopy(self.config_queue_handler)
from multiprocessing import Queue as MQ, Manager as MM
q1 = MQ() # this can't be pickled
q2 = MM().Queue() # a proxy queue for use when pickling is needed
for qspec in (q1, q2):
q3 = MM().JoinableQueue() # a joinable proxy queue
for qspec in (q1, q2, q3):
fn = make_temp_file('.log', 'test_logging-cmpqh-')
cd['handlers']['h1']['filename'] = fn
cd['handlers']['ah']['queue'] = qspec
Expand Down

0 comments on commit 983efcf

Please sign in to comment.