Skip to content

Commit ea659dd

Browse files
committed
mitogen/parent: Make the timeout configurable
-SSH command size: 894 +SSH command size: 905 Original Minimized Compressed -mitogen.parent 99034 96.7KiB 51295 50.1KiB 51.8% 12970 12.7KiB 13.1% +mitogen.parent 99212 96.9KiB 51385 50.2KiB 51.8% 12999 12.7KiB 13.1% Signed-off-by: Marc Hartmayer <[email protected]>
1 parent 51e76d7 commit ea659dd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mitogen/parent.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,9 @@ class Connection(object):
13781378
#: user.
13791379
exception = None
13801380

1381+
#: First stage timeout in seconds.
1382+
_first_stage_timeout = 10
1383+
13811384
#: Extra text appended to :class:`EofError` if that exception is raised on
13821385
#: a failed connection attempt. May be used in subclasses to hint at common
13831386
#: problems with a particular connection method.
@@ -1419,6 +1422,7 @@ def __repr__(self):
14191422
# n: size of the compressed core source to be read
14201423
# V: data chunk
14211424
# rl: list of FDs ready for reading
1425+
# t: timeout value in seconds
14221426
# _: throw away variable
14231427

14241428
# Final os.close(STDOUT_FILENO) to avoid --py-debug build corrupting stream with
@@ -1442,10 +1446,11 @@ def _first_stage():
14421446
os.execl(sys.executable,sys.executable+'(mitogen:%s)'%sys.argv[2])
14431447
os.write(1,'MITO000\n'.encode())
14441448
n=int(sys.argv[3])
1449+
t=float(sys.argv[4])
14451450
C=''.encode()
14461451
V='V'
14471452
while n>len(C) and V:
1448-
rl,_,_=select.select([0],[],[],10)
1453+
rl,_,_=select.select([0],[],[],t)
14491454
if not rl:
14501455
raise Exception("TimeoutError")
14511456
V=os.read(0,n-len(C))
@@ -1495,6 +1500,7 @@ def get_boot_command(self):
14951500
encoded.decode(),
14961501
self.options.remote_name,
14971502
str(len(self.get_preamble())),
1503+
str(self._first_stage_timeout),
14981504
]
14991505

15001506
def get_econtext_config(self):

0 commit comments

Comments
 (0)