Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Emile van Sebille Newsgroups: comp.lang.python Subject: Re: child.before taking almost 1 minute to execute Date: Wed, 24 Feb 2016 12:57:31 -0800 Lines: 20 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de ntnVfTxvXIvXeR1hBSFy1wZS+dpxsYGJ7GeMBNeUv1qQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; "'no": 0.09; 'eof': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'snippet': 0.09; 'result.': 0.15; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'sys.exit(1)': 0.16; 'timeout,': 0.16; 'wrote:': 0.16; 'skip:% 10': 0.22; 'am,': 0.23; 'header:In-Reply- To:1': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints- To:1': 0.26; 'looks': 0.29; '"no': 0.29; 'print': 0.30; "i'd": 0.31; 'guess': 0.31; 'file': 0.34; 'skip:p 30': 0.35; 'there': 0.36; 'alone': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'wrong': 0.38; 'skip:o 20': 0.38; 'to:addr:python.org': 0.40; 'your': 0.60; 'charset:windows-1252': 0.62; 'complete': 0.63; 'received:12': 0.81; 'subject:minute': 0.84 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: www.westernstatesglass.com User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:103458 On 2/24/2016 7:42 AM, pyfreek wrote: > The following snippet alone is taking 1 minute to execute. is there any best way to find 'No such file' other than using child.before > > if not scrutinFile.startswith('/') : > scrutinFile = '/'+ scrutinFile > scrutinFileFtp = directory + scrutinFile > filePath, file = os.path.split(scrutinFileFtp) > p.sendline('cd %s'%(filePath)) > p.expect([pexpect.EOF,pexpect.TIMEOUT]) > if 'No such file' in p.before: > print "No such directory exists!!" > sys.exit(1) I'd guess that you've got your p.expect line wrong -- it looks to me like you're allowing that line to complete only upon seeing an EOF or TIMEOUT, and that it's timing out as a result. Emile