Skip to content

Commit 3f4161c

Browse files
authored
Merge pull request #79 from bits01/run_command_on_app_fixes
Fixed run_command_on_app issues with size and timeout
2 parents 7e81f7a + 073f31e commit 3f4161c

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

heroku3/api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,8 @@ def oauthtoken_create(self, client_secret=None, grant_code=None, grant_type=None
479479
item = self._resource_deserialize(r.content.decode("utf-8"))
480480
return OAuthToken.new_from_dict(item, h=self)
481481

482-
def run_command_on_app(self, appname, command, size=1, attach=True, printout=True, env=None):
482+
def run_command_on_app(self, appname, command, size='standard-1x', attach=True, printout=True, env=None,
483+
timeout_secs=60):
483484
"""Run a remote command attach=True if you want to capture the output"""
484485
if attach:
485486
attach = True
@@ -497,7 +498,7 @@ def run_command_on_app(self, appname, command, size=1, attach=True, printout=Tru
497498
dyno = Dyno.new_from_dict(item, h=self)
498499

499500
if attach:
500-
output = Rendezvous(dyno.attach_url, printout).start()
501+
output = Rendezvous(dyno.attach_url, printout=printout, timeout_secs=timeout_secs).start()
501502
return output, dyno
502503
else:
503504
return dyno

heroku3/rendezvous.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
class InvalidResponseFromRendezVous(Exception):
1313
pass
1414

15-
16-
class Rendezvous:
17-
def __init__(self, url, printout=False):
15+
16+
class Rendezvous():
17+
def __init__(self, url, printout=False, timeout_secs=29):
1818
self.url = url
1919
urlp = urlparse(url)
2020
self.hostname = urlp.hostname
@@ -26,6 +26,7 @@ def __init__(self, url, printout=False):
2626
self.cert = os.path.abspath("{0}/data/cacert.pem".format(path))
2727
self.data = ""
2828
self.printout = printout
29+
self.timeout_secs = timeout_secs
2930

3031
def start(self):
3132

@@ -47,7 +48,8 @@ def start(self):
4748
# #ssl_version=ssl.PROTOCOL_TLSv1_1
4849
# )
4950

50-
ssl_sock.settimeout(30)
51+
ssl_sock.settimeout(self.timeout_secs)
52+
5153
ssl_sock.connect((self.hostname, self.port))
5254
# ssl_sock.setblocking(1)
5355
ssl_sock.write(self.secret.encode("utf8"))

0 commit comments

Comments
 (0)