<s> '''<STR_LIT>''' <EOL> from __future__ import absolute_import <EOL> import multiprocessing <EOL> import logging <EOL> import salt <EOL> import salt . loader <EOL> import salt . utils <EOL> from salt . utils . process import SignalHandlingMultiprocessingProcess <EOL> log = logging . getLogger ( __name__ ) <EOL> def start_engines ( opts , proc_mgr , proxy = None ) : <EOL> '''<STR_LIT>''' <EOL> if opts [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> runners = salt . loader . runner ( opts ) <EOL> else : <EOL> runners = [ ] <EOL> utils = salt . loader . utils ( opts ) <EOL> funcs = salt . loader . minion_mods ( opts , utils = utils ) <EOL> engines = salt . loader . engines ( opts , funcs , runners , proxy = proxy ) <EOL> engines_opt = opts . get ( '<STR_LIT>' , [ ] ) <EOL> if isinstance ( engines_opt , dict ) : <EOL> engines_opt = [ { k : v } for k , v in engines_opt . items ( ) ] <EOL> if salt . utils . is_windows ( ) : <EOL> runners = None <EOL> utils = None <EOL> funcs = None <EOL> for engine in engines_opt : <EOL> if isinstance ( engine , dict ) : <EOL> engine , engine_opts = next ( iter ( engine . items ( ) ) ) <EOL> else : <EOL> engine_opts = None <EOL> fun = '<STR_LIT>' . format ( engine ) <EOL> if fun in engines : <EOL> start_func = engines [ fun ] <EOL> name = '<STR_LIT>' . format ( __name__ , start_func . __module__ ) <EOL> log . info ( '<STR_LIT>' . format ( name ) ) <EOL> proc_mgr . add_process ( <EOL> Engine , <EOL> args = ( <EOL> opts , <EOL> fun , <EOL> engine_opts , <EOL> funcs , <EOL> runners , <EOL> proxy <EOL> ) , <EOL> name = name <EOL> ) <EOL> class Engine ( SignalHandlingMultiprocessingProcess ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , opts , fun , config , funcs , runners , proxy , log_queue = None ) : <EOL> '''<STR_LIT>''' <EOL> super ( Engine , self ) . __init__ ( log_queue = log_queue ) <EOL> self . opts = opts <EOL> self . config = config <EOL> self . fun = fun <EOL> self . funcs = funcs <EOL> self . runners = runners <EOL> self . proxy = proxy <EOL> def __setstate__ ( self , state ) : <EOL> self . _is_child = True <EOL> self . __init__ ( <EOL> state [ '<STR_LIT>' ] , <EOL> state [ '<STR_LIT>' ] , <EOL> state [ '<STR_LIT>' ] , <EOL> state [ '<STR_LIT>' ] , <EOL> state [ '<STR_LIT>' ] , <EOL> state [ '<STR_LIT>' ] , <EOL> log_queue = state [ '<STR_LIT>' ] <EOL> ) <EOL> def __getstate__ ( self ) : <EOL> return { '<STR_LIT>' : self . opts , <EOL> '<STR_LIT>' : self . fun , <EOL> '<STR_LIT>' : self . config , <EOL> '<STR_LIT>' : self . funcs , <EOL> '<STR_LIT>' : self . runners , <EOL> '<STR_LIT>' : self . proxy , <EOL> '<STR_LIT>' : self . log_queue } <EOL> def run ( self ) : <EOL> '''<STR_LIT>''' <EOL> if salt . utils . is_windows ( ) : <EOL> if self . opts [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> self . runners = salt . loader . runner ( self . opts ) <EOL> else : <EOL> self . runners = [ ] <EOL> self . utils = salt . loader . utils ( self . opts ) <EOL> self . funcs = salt . loader . minion_mods ( self . opts , utils = self . utils ) <EOL> self . engine = salt . loader . engines ( self . opts , <EOL> self . funcs , <EOL> self . runners , <EOL> proxy = self . proxy ) <EOL> kwargs = self . config or { } <EOL> try : <EOL> self . engine [ self . fun ] ( ** kwargs ) <EOL> except Exception as exc : <EOL> log . critical ( '<STR_LIT>' . format ( self . engine , exc ) ) </s>
