pyinfra turns Python code into shell commands and runs them on your servers. Execute ad-hoc commands and write declarative operations. Target SSH servers, local machine and Docker containers. Fast and scales from one server to thousands.
The is still some CycleErrors when using embedded loops. Especially, it looks like the host.loop_position is shared across all hosts.
To Reproduce
I can consistently reproduce the issue with following simple script and 2 hosts.
import random
import time
from pyinfra import host
from pyinfra.operations import server
for i in host.loop(range(0, 3)):
for j in host.loop(range(0, 3)):
print(f"{host.name} {host.loop_position}")
server.shell(name=f"ls A", commands="ls")
if random.randint(0, 1) == 0:
time.sleep(1)
server.shell(name=f"ls B", commands="ls")
server.shell(name=f"ls C", commands="ls")
The print will show something going wrong in the handling for host.loop_position.
Meta
v2.5.2
Output of previous example shows issues in host.loop_position.
Describe the bug
The is still some CycleErrors when using embedded loops. Especially, it looks like the
host.loop_position
is shared across all hosts.To Reproduce
I can consistently reproduce the issue with following simple script and 2 hosts.
The
print
will show something going wrong in the handling forhost.loop_position
.Meta
v2.5.2
Output of previous example shows issues in
host.loop_position
.