Park JeongHoon
Park JeongHoon

Reputation: 11

what is difference from parallel option and no-wait option in pyinfra

I wonder what is difference from parallel option and no-wait option in pyinfra.

I understand parallel option controls the number of host at once and no-wait option controls if the host operations work in parallel.

Do I misunderstand the options?

I ran the command that 'pyinfra inventory.py test_operation.py test_operation2.py'

# test_operation.py
from pyinfra.operations import python, server
import gevent
result = server.shell(
    commands=["ls"],
)

def callback():
    import time
    time.sleep(5)
    print(f"Got result: {result.stdout}")

python.call(
    name="Execute callback function",
    function=callback,
)
# test_operation2.py
from pyinfra.operations import python, server

result = server.shell(
    commands=["ls"],
)

def callback():
    import time
    time.sleep(5)
    print(f"Got result22222222: {result.stdout}")

python.call(
    name="Execute callback function",
    function=callback,
)

Upvotes: 1

Views: 114

Answers (1)

Fizzadar
Fizzadar

Reputation: 401

For single operations the flags are identical, the difference is when using multiple operations. Specifically the --parallel operation controls how many hosts to run each operation on in parallel. pyinfra will still wait after each operation for all hosts to complete it.

With --no-wait this wait between operations is removed and each host will execute every operation as quickly as possible.

Upvotes: 0

Related Questions