Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pexpect timeout is not being used, only the default of 30 is being used

Tags:

python

pexpect

I'm trying to do a lengthy operation but pexpect with the timeout argument doesn't seem to change the length of time before the timeout exception gets fired. Here is my code:

child = pexpect.spawn('scp file user@:/temp', timeout=300)

whichMatched = child.expect(['(?i)Password','Are you sure you want to continue connecting (yes/no)?'], timeout=300)

The exception shows that the timeout=30, which is the default.

after: <class 'pexpect.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 6222
child_fd: 4
closed: False
timeout: 30
delimiter: <class 'pexpect.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
like image 964
darrickc Avatar asked Jul 26 '10 20:07

darrickc


1 Answers

It appears to work if you only specify the timeout in the .spawn call, you cannot override, or use timeout=300 in the .expect call by itself.

like image 180
darrickc Avatar answered Oct 05 '22 07:10

darrickc