MCPcopy Index your code
hub / github.com/pyinvoke/invoke / run

Method run

invoke/runners.py:126–406  ·  view source on GitHub ↗

Execute ``command``, returning an instance of `Result` once complete. By default, this method is synchronous (it only returns once the subprocess has completed), and allows interactive keyboard communication with the subprocess. It can instead behave asynch

(self, command: str, **kwargs: Any)

Source from the content-addressed store, hash-verified

124 self._disowned = False
125
126 def run(self, command: str, **kwargs: Any) -> "Result":
127 """
128 Execute ``command``, returning an instance of `Result` once complete.
129
130 By default, this method is synchronous (it only returns once the
131 subprocess has completed), and allows interactive keyboard
132 communication with the subprocess.
133
134 It can instead behave asynchronously (returning early & requiring
135 interaction with the resulting object to manage subprocess lifecycle)
136 if you specify ``asynchronous=True``. Furthermore, you can completely
137 disassociate the subprocess from Invoke's control (allowing it to
138 persist on its own after Python exits) by saying ``disown=True``. See
139 the per-kwarg docs below for details on both of these.
140
141 .. note::
142 All kwargs will default to the values found in this instance's
143 `~.Runner.context` attribute, specifically in its configuration's
144 ``run`` subtree (e.g. ``run.echo`` provides the default value for
145 the ``echo`` keyword, etc). The base default values are described
146 in the parameter list below.
147
148 :param str command: The shell command to execute.
149
150 :param bool asynchronous:
151 When set to ``True`` (default ``False``), enables asynchronous
152 behavior, as follows:
153
154 - Connections to the controlling terminal are disabled, meaning you
155 will not see the subprocess output and it will not respond to
156 your keyboard input - similar to ``hide=True`` and
157 ``in_stream=False`` (though explicitly given
158 ``(out|err|in)_stream`` file-like objects will still be honored
159 as normal).
160 - `.run` returns immediately after starting the subprocess, and its
161 return value becomes an instance of `Promise` instead of
162 `Result`.
163 - `Promise` objects are primarily useful for their `~Promise.join`
164 method, which blocks until the subprocess exits (similar to
165 threading APIs) and either returns a final `~Result` or raises an
166 exception, just as a synchronous ``run`` would.
167
168 - As with threading and similar APIs, users of
169 ``asynchronous=True`` should make sure to ``join`` their
170 `Promise` objects to prevent issues with interpreter
171 shutdown.
172 - One easy way to handle such cleanup is to use the `Promise`
173 as a context manager - it will automatically ``join`` at the
174 exit of the context block.
175
176 .. versionadded:: 1.4
177
178 :param bool disown:
179 When set to ``True`` (default ``False``), returns immediately like
180 ``asynchronous=True``, but does not perform any background work
181 related to that subprocess (it is completely ignored). This allows
182 subprocesses using shell backgrounding or similar techniques (e.g.
183 trailing ``&``, ``nohup``) to persist beyond the lifetime of the

Callers 10

integrationFunction · 0.45
regressionFunction · 0.45
typecheckFunction · 0.45
_hang_on_full_pipeMethod · 0.45
calls_fooFunction · 0.45
fooFunction · 0.45
checkFunction · 0.45
__main__.pyFile · 0.45
runFunction · 0.45

Calls 2

_run_bodyMethod · 0.95
stopMethod · 0.95

Tested by

no test coverage detected