# Buggy code
def process_log_level(self):
    if not self.options.log_level:
        cli_log_level = "cli_{0}_log_level".format(
            self.get_prog_name().replace("-", "_")
        )
        if self.config.get(cli_log_level, None) is not None:
            self.options.log_level = self.config.get(cli_log_level)
        elif self.config.get(self._loglevel_config_setting_name_, None):
            self.options.log_level = self.config.get(
                self._loglevel_config_setting_name_
            )
        else:
            self.options.log_level = self._default_logging_level_

    # Setup extended logging right before the last step
    self._mixin_after_parsed_funcs.append(self.__setup_extended_logging)
    # Setup the multiprocessing log queue listener if enabled
    self._mixin_after_parsed_funcs.append(self.__setup_mp_logging_listener)
    # Setup the console as the last _mixin_after_parsed_func to run
    self._mixin_after_parsed_funcs.append(self.__setup_console_logger)


# Traceback (AssertionError)
root@nitin-salt-develop:~/salt$ service salt-master stop
Stopping salt-master daemon:                               [  OK  ]
root@nitin-salt-develop:~/salt$ service salt-master start
Starting salt-master daemon: Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib64/python2.6/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib64/python2.6/multiprocessing/util.py", line 269, in _exit_function
p.join()
File "/usr/lib64/python2.6/multiprocessing/process.py", line 117, in join
assert self._parent_pid == os.getpid(), 'can only join a child process'
AssertionError: can only join a child process
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib64/python2.6/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib64/python2.6/multiprocessing/util.py", line 269, in _exit_function
p.join()
File "/usr/lib64/python2.6/multiprocessing/process.py", line 117, in join
assert self._parent_pid == os.getpid(), 'can only join a child process'
AssertionError: can only join a child process
^CError in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib64/python2.6/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib64/python2.6/multiprocessing/util.py", line 269, in _exit_function
p.join()
File "/usr/lib64/python2.6/multiprocessing/process.py", line 119, in join
res = self._popen.wait(timeout)
File "/usr/lib64/python2.6/multiprocessing/forking.py", line 122, in wait
return self.poll(0)
File "/usr/lib64/python2.6/multiprocessing/forking.py", line 107, in poll
pid, sts = os.waitpid(self.pid, flag)
KeyboardInterrupt
Error in sys.exitfunc:
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/log/setup.py", line 906, in __global_logging_exception_handler
shutdown_multiprocessing_logging_listener()
File "/usr/lib/python2.6/site-packages/salt/log/setup.py", line 800, in shutdown_multiprocessing_logging_listener
__MP_LOGGING_QUEUE_PROCESS.terminate()
File "/usr/lib64/python2.6/multiprocessing/process.py", line 111, in terminate
self._popen.terminate()
File "/usr/lib64/python2.6/multiprocessing/forking.py", line 139, in terminate
os.kill(self.pid, signal.SIGTERM)
OSError: [Errno 3] No such process

Original exception was:
Traceback (most recent call last):
File "/usr/lib64/python2.6/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib64/python2.6/multiprocessing/util.py", line 269, in _exit_function
p.join()
File "/usr/lib64/python2.6/multiprocessing/process.py", line 119, in join
res = self._popen.wait(timeout)
File "/usr/lib64/python2.6/multiprocessing/forking.py", line 122, in wait
return self.poll(0)
File "/usr/lib64/python2.6/multiprocessing/forking.py", line 107, in poll
pid, sts = os.waitpid(self.pid, flag)
KeyboardInterrupt
[  OK  ]

# Fixed code
def process_log_level(self):
    if not self.options.log_level:
        cli_log_level = "cli_{0}_log_level".format(
            self.get_prog_name().replace("-", "_")
        )
        if self.config.get(cli_log_level, None) is not None:
            self.options.log_level = self.config.get(cli_log_level)
        elif self.config.get(self._loglevel_config_setting_name_, None):
            self.options.log_level = self.config.get(
                self._loglevel_config_setting_name_
            )
        else:
            self.options.log_level = self._default_logging_level_

    # Setup extended logging right before the last step
    self._mixin_after_parsed_funcs.append(self.__setup_extended_logging)
    # Setup the multiprocessing log queue listener if enabled
    self._mixin_after_parsed_funcs.append(self._setup_mp_logging_listener)
    # Setup the console as the last _mixin_after_parsed_func to run
    self._mixin_after_parsed_funcs.append(self.__setup_console_logger)