Skip to content

Commit faa366e

Browse files
wackouFizzadar
authored andcommitted
server.reboot: properly disconnect before trying to reconnect
Otherwise the `reboot` operation will assume we are already connected after the initial delay and will go on even though we don't have a valid connection.
1 parent b0ce3b0 commit faa366e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

pyinfra/api/host.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ def disconnect(self):
412412
remove_any_sudo_askpass_file(self)
413413

414414
self.state.trigger_callbacks("host_disconnect", self)
415+
self.connected = False
415416

416417
def run_shell_command(self, *args, **kwargs) -> tuple[bool, CommandOutput]:
417418
"""

pyinfra/operations/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def wait_and_reconnect(state, host): # pragma: no cover
8989
sleep(delay)
9090
max_retries = round(reboot_timeout / interval)
9191

92-
host.connection = None # remove the connection object
92+
host.disconnect() # make sure we are properly disconnected
9393
retries = 0
9494

9595
while True:

0 commit comments

Comments
 (0)