File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -46,5 +46,22 @@ def connect_all(state: "State"):
46
46
47
47
48
48
def disconnect_all (state : "State" ):
49
- for host in state .activated_hosts : # only hosts we connected to please!
50
- host .disconnect () # normally a noop
49
+ """
50
+ Disconnect from all of the configured servers in parallel. Reads/writes state.inventory.
51
+
52
+ Args:
53
+ state (``pyinfra.api.State`` obj): the state containing an inventory to connect to
54
+ """
55
+ greenlet_to_host = {
56
+ state .pool .spawn (host .disconnect ): host
57
+ for host in state .activated_hosts # only hosts we connected to please!
58
+ }
59
+
60
+ with progress_spinner (greenlet_to_host .values ()) as progress :
61
+ for greenlet in gevent .iwait (greenlet_to_host .keys ()):
62
+ host = greenlet_to_host [greenlet ]
63
+ progress (host )
64
+
65
+ for greenlet , host in greenlet_to_host .items ():
66
+ # Raise any unexpected exception
67
+ greenlet .get ()
You can’t perform that action at this time.
0 commit comments