Skip to content

Commit

Permalink
Change run_async() to match run()
Browse files Browse the repository at this point in the history
  • Loading branch information
Shrews committed Oct 14, 2024
1 parent 06cbaa9 commit 5fbae20
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ disable = [
"C0115", # missing-class-docstring
"C0116", # missing-function-docstring
"C0301", # line-too-long
"C0302", # too-many-lines
"R0401", # cyclic-import
"R0801", # duplicate-code
"R0902", # too-many-instance-attributes
Expand Down
25 changes: 23 additions & 2 deletions src/ansible_runner/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,36 @@ def run(config: RunnerConfig | None = None,
return r


def run_async(**kwargs):
def run_async(
config: RunnerConfig | None = None,
streamer: str = "",
debug: bool = False,
logfile: str = "",
ignore_logging: bool = True,
_input: io.FileIO | None = None,
_output: io.FileIO | None = None,
only_transmit_kwargs: bool = False,
**kwargs):
'''
Runs an Ansible Runner task in the background which will start immediately. Returns the thread object and a Runner object.
This uses the same parameters as :py:func:`ansible_runner.interface.run`
:returns: A tuple containing a :py:class:`threading.Thread` object and a :py:class:`ansible_runner.runner.Runner` object
'''
r = init_runner(**kwargs)

# Initialize logging
if not ignore_logging:
output.configure(debug, logfile)

if not config:
config = RunnerConfig(**kwargs)

r = init_runner(
config=config, streamer=streamer,
only_transmit_kwargs=only_transmit_kwargs,
_input=_input, _output=_output,
)
runner_thread = threading.Thread(target=r.run)
runner_thread.start()
return runner_thread, r
Expand Down

0 comments on commit 5fbae20

Please sign in to comment.