Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disconnecting from host with Python Fabric when using the API

Tags:

python

fabric

The website says:

Closing connections: Fabric’s connection cache never closes connections itself – it leaves this up to whatever is using it. The fab tool does this bookkeeping for you: it iterates over all open connections and closes them just before it exits (regardless of whether the tasks failed or not.)

Library users will need to ensure they explicitly close all open connections before their program exits, though we plan to makes this easier in the future.

I have searched everywhere, but I can't find out how to disconnect or close the connections. I am looping through my hosts and setting env.host_string. It is working, but hangs when exiting. Any help on how to close? Just to reiterate, I am using the library, not a fabfile.

like image 881
Amala Avatar asked Aug 02 '10 22:08

Amala


1 Answers

If you don't want to have to iterate through all open connections, fabric.network.disconnect_all() is what you're looking for. The docstring reads

"""
Disconnect from all currently connected servers. Used at the end of fab's main loop, and also intended for use by library users.
"""

like image 137
Maascamp Avatar answered Oct 05 '22 22:10

Maascamp