MCPcopy Create free account
hub / github.com/saltstack/salt / enter_mainloop

Function enter_mainloop

salt/cloud/__init__.py:72–169  ·  view source on GitHub ↗

Manage a multiprocessing pool - If the queue does not output anything, the pool runs indefinitely - If the queue returns KEYBOARDINT or ERROR, this will kill the pool totally calling terminate & join and ands with a SaltCloudSystemExit exception notifying callers from the

(
    target,
    mapped_args=None,
    args=None,
    kwargs=None,
    pool=None,
    pool_size=None,
    callback=None,
    queue=None,
)

Source from the content-addressed store, hash-verified

70
71
72def enter_mainloop(
73 target,
74 mapped_args=None,
75 args=None,
76 kwargs=None,
77 pool=None,
78 pool_size=None,
79 callback=None,
80 queue=None,
81):
82 """
83 Manage a multiprocessing pool
84
85 - If the queue does not output anything, the pool runs indefinitely
86
87 - If the queue returns KEYBOARDINT or ERROR, this will kill the pool
88 totally calling terminate & join and ands with a SaltCloudSystemExit
89 exception notifying callers from the abnormal termination
90
91 - If the queue returns END or callback is defined and returns True,
92 it just join the process and return the data.
93
94 target
95 the function you want to execute in multiprocessing
96 pool
97 pool object can be None if you want a default pool, but you ll
98 have then to define pool_size instead
99 pool_size
100 pool size if you did not provide yourself a pool
101 callback
102 a boolean taking a string in argument which returns True to
103 signal that 'target' is finished and we need to join
104 the pool
105 queue
106 A custom multiprocessing queue in case you want to do
107 extra stuff and need it later in your program
108 args
109 positional arguments to call the function with
110 if you don't want to use pool.map
111
112 mapped_args
113 a list of one or more arguments combinations to call the function with
114 e.g. (foo, [[1], [2]]) will call::
115
116 foo([1])
117 foo([2])
118
119 kwargs
120 kwargs to give to the function in case of process
121
122 Attention, the function must have the following signature:
123
124 target(queue, *args, **kw)
125
126 You may use the 'communicator' decorator to generate such a function
127 (see end of this file)
128 """
129 if not kwargs:

Callers 3

destroyMethod · 0.85
run_mapMethod · 0.85

Calls 9

SaltCloudSystemExitClass · 0.90
callbackFunction · 0.85
formatMethod · 0.80
errorMethod · 0.45
applyMethod · 0.45
getMethod · 0.45
terminateMethod · 0.45
closeMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected