mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #45707 from skizunov/develop2
Fix exception when shutting down logging listener
This commit is contained in:
commit
38ed46a61a
2 changed files with 14 additions and 0 deletions
|
@ -933,6 +933,12 @@ def shutdown_multiprocessing_logging():
|
|||
logging.root.removeHandler(__MP_LOGGING_QUEUE_HANDLER)
|
||||
__MP_LOGGING_QUEUE_HANDLER = None
|
||||
__MP_LOGGING_CONFIGURED = False
|
||||
if not logging.root.handlers:
|
||||
# Ensure we have at least one logging root handler so
|
||||
# something can handle logging messages. This case should
|
||||
# only occur on Windows since on Windows we log to console
|
||||
# and file through the Multiprocessing Logging Listener.
|
||||
setup_console_logger()
|
||||
finally:
|
||||
logging._releaseLock()
|
||||
|
||||
|
@ -946,6 +952,12 @@ def shutdown_multiprocessing_logging_listener(daemonizing=False):
|
|||
# We're in the MainProcess and we're not daemonizing, return!
|
||||
# No multiprocessing logging listener shutdown shall happen
|
||||
return
|
||||
|
||||
if not daemonizing:
|
||||
# Need to remove the queue handler so that it doesn't try to send
|
||||
# data over a queue that was shut down on the listener end.
|
||||
shutdown_multiprocessing_logging()
|
||||
|
||||
if __MP_LOGGING_QUEUE_PROCESS is None:
|
||||
return
|
||||
if __MP_LOGGING_QUEUE_PROCESS.is_alive():
|
||||
|
|
|
@ -261,6 +261,8 @@ class OptionParser(optparse.OptionParser, object):
|
|||
)
|
||||
)
|
||||
if self._setup_mp_logging_listener_ is True:
|
||||
# Stop logging through the queue
|
||||
log.shutdown_multiprocessing_logging()
|
||||
# Stop the logging queue listener process
|
||||
log.shutdown_multiprocessing_logging_listener(daemonizing=True)
|
||||
if isinstance(msg, six.string_types) and msg and msg[-1] != '\n':
|
||||
|
|
Loading…
Add table
Reference in a new issue