Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fabric 2 : connect_timeout not working #1913

Open
hd40910 opened this issue Dec 5, 2018 · 2 comments
Open

Fabric 2 : connect_timeout not working #1913

hd40910 opened this issue Dec 5, 2018 · 2 comments

Comments

@hd40910
Copy link

hd40910 commented Dec 5, 2018

from datetime import datetime
from fabric2 import connection

start = datetime.now()
connect = connection.Connection(host="root@vptest01",
connect_kwargs={"password": "somepass"},
gateway=None,
connect_timeout=2)

print connect.run("sleep 10 && hostname", warn=True, shell="/bin/bash -c", pty=False)
print "Time Taken: "+ str((datetime.now()-start).total_seconds())

'''
Output:

vptest01
Command exited with status 0.
=== stdout ===
vptest01

(no stderr)
Time Taken: 13.785

'''

I am trying to run a command, but I dont want to wait for more than 2 seconds. Am I doing something wrong ? Looks like connect_timeout does not work ??

@dhdavvie
Copy link

dhdavvie commented Dec 7, 2018

New here so I may be wrong but by the looks of it, connect_timeout is for TCP connection timeouts ie "I haven't heard back from the server in x seconds". In this case, the client doesn't just send the run command and waits 10 seconds without hearing anything from the server. Instead, the client sends a run request, the server acknowledges the run request, and then at a later point initiates the return transmission. The client doesn't ever sit without a reply for 2 seconds in a normal scenario with good connection to the server.

You might want to have a look at the timeout utility.

Again, new here so take everything I've said with a grain of salt until someone else can vouch for it :)

@hd40910
Copy link
Author

hd40910 commented Dec 7, 2018

Thanks @dhdavvie. @bitprophet actually advised to use connect_timeout in another thread
#762 ...It was a year ago so I opened a new one :(

Am stuck in this part were the FS gets full, fabric2 thread throws below given prompt and then this just sits there forever blocking the main thread.
Sorry, I am also a novice and I believe am doing something wrong in fabric2 as it used to work fine in fabric

]: fabric2:runCommand: '/bin/ksh -c . ~/.profile ; unzip packages/somepath/*.zip -d packages/somepath/' is being executed on: xxxx@xxxx:22.Retries Left: 3
]:inflating: packages/somepath/something.ear
]: packages/somepath/something.ear: write error (disk full?). Continue? (y/n/^C)

timeout is nice :) .But is there something in python that I can club with fabric2 to achieve this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants