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 5e28eea
Showing 1 changed file with 23 additions and 2 deletions.
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 5e28eea

Please sign in to comment.