cpython: 26c3d170fd56 (original) (raw)

Mercurial > cpython

changeset 79407:26c3d170fd56

Issue #15452: Added verify option for logging configuration socket listener. [#15452]

Vinay Sajip <vinay_sajip@yahoo.co.uk>
date Tue, 02 Oct 2012 15:56:16 +0100
parents 76435de68379
children 6df80e09ad5e
files Doc/library/logging.config.rst Lib/logging/config.py Lib/test/test_logging.py
diffstat 3 files changed, 115 insertions(+), 27 deletions(-)[+] [-] Doc/library/logging.config.rst 20 Lib/logging/config.py 46 Lib/test/test_logging.py 76

line wrap: on

line diff

--- a/Doc/library/logging.config.rst +++ b/Doc/library/logging.config.rst @@ -95,7 +95,7 @@ in :mod:logging itself) and defining h logging configuration. -.. function:: listen(port=DEFAULT_LOGGING_CONFIG_PORT) +.. function:: listen(port=DEFAULT_LOGGING_CONFIG_PORT, verify=None) Starts up a socket server on the specified port, and listens for new configurations. If no port is specified, the module's default @@ -105,6 +105,17 @@ in :mod:logging itself) and defining h server, and which you can :meth:join when appropriate. To stop the server, call :func:stopListening.

+

.. function:: stopListening()

--- a/Lib/logging/config.py +++ b/Lib/logging/config.py @@ -773,7 +773,7 @@ def dictConfig(config): dictConfigClass(config).configure() -def listen(port=DEFAULT_LOGGING_CONFIG_PORT): +def listen(port=DEFAULT_LOGGING_CONFIG_PORT, verify=None): """ Start up a socket server on the specified port, and listen for new configurations. @@ -809,22 +809,25 @@ def listen(port=DEFAULT_LOGGING_CONFIG_P chunk = self.connection.recv(slen) while len(chunk) < slen: chunk = chunk + conn.recv(slen - len(chunk))

@@ -843,13 +846,14 @@ def listen(port=DEFAULT_LOGGING_CONFIG_P allow_reuse_address = 1 def init(self, host='localhost', port=DEFAULT_LOGGING_CONFIG_PORT,

def serve_until_stopped(self): import select @@ -867,16 +871,18 @@ def listen(port=DEFAULT_LOGGING_CONFIG_P class Server(threading.Thread):

def run(self): server = self.rcvr(port=self.port, handler=self.hdlr,

@@ -886,7 +892,7 @@ def listen(port=DEFAULT_LOGGING_CONFIG_P logging._releaseLock() server.serve_until_stopped()

def stopListening(): """

--- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -150,14 +150,17 @@ class BaseTest(unittest.TestCase): finally: logging._releaseLock()

@@ -2601,10 +2604,10 @@ class ConfigDictTest(BaseTest): self.assertRaises(Exception, self.apply_config, self.config13) @unittest.skipUnless(threading, 'listen() needs threading to work')

@@ -2664,6 +2667,69 @@ class ConfigDictTest(BaseTest): # Original logger output is empty. self.assert_log_lines([])

+

+

+

+

+

+

+

+ def test_baseconfig(self): d = { 'atuple': (1, 2, 3),