Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'explicitly': 0.05; 'handler': 0.05; 'lines,': 0.07; 'executed': 0.09; 'executes': 0.09; 'function,': 0.09; 'subject:script': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; '(either': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'i.e': 0.16; 'sane': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'library': 0.18; 'bit': 0.19; 'thu,': 0.19; '(in': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'sort': 0.25; 'script': 0.25; 'mention': 0.26; 'nearly': 0.26; 'query': 0.26; 'primary': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'lines': 0.31; 'usually': 0.31; 'trace': 0.31; 'probably': 0.32; 'figure': 0.32; 'run': 0.32; 'running': 0.33; 'subject:the': 0.34; 'something': 0.35; 'case,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'executing': 0.36; 'useful': 0.36; 'seconds': 0.37; 'button': 0.38; '12,': 0.39; 'sure': 0.39; 'either': 0.39; 'how': 0.40; 'complete': 0.62; 'more': 0.64; 'within': 0.65; 'effectively': 0.66; 'background:': 0.68; 'informed': 0.78; '(no.': 0.84; '80%': 0.84; 'execution.': 0.84; 'treats': 0.84; 'viable': 0.84; 'to:none': 0.92; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=145lw75WMDPGOttUOZ1rDLRsxYdovZ3RQel+xQC8oOY=; b=TMYVgYBXIz9Hx07/yvhP4/pXB79DaQbuKK8Wy9curqXyzljKTSK1oOb5jL7dXBRSdy +CgziBNsnBZMYbWHXAzAniISgPj9bfbjSqthMB2E8CHb5cY6+3LfHVxgll9WkhIiekgP luIbsB3NW9dNDJ/6VA0aFavc60hAlUgt02aipNGR+L7LGWEr8JSkvdFqY5qXMuE1KBlX PgZ8a5R83g3qR7oYfCpK0aRVqGja4J3jD4HXYdDjvw1V5U3SmCa5re8vHrYjTnQLZKKp GG2xCgw3kAaijqbI3ZC82ac8Ng4uL5WtnsSeLlQVb1tSsDxKRQFZl2956smDMG07UXpB 2qTw== MIME-Version: 1.0 X-Received: by 10.68.228.97 with SMTP id sh1mr4245147pbc.50.1386790464664; Wed, 11 Dec 2013 11:34:24 -0800 (PST) In-Reply-To: References: Date: Thu, 12 Dec 2013 06:34:24 +1100 Subject: Re: Tracking the status of python script execution From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1386790844 news.xs4all.nl 2975 [2001:888:2000:d::a6]:34545 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:61611 On Thu, Dec 12, 2013 at 6:26 AM, Shyam Parimal Katti wrote: > I am looking for a library that can help me trace the status of a live > python script execution. i.e if I have a python script `x.py` with 200 > lines, when I execute the script with `python x.py`, is there a way to trace > the status of this execution in terms of number of lines executed so far? > > Background: We have a Web page with "Run" button that executes the program > `x.py` when a user clicks it. We were looking of a way to keep the user > informed about the status of run by using: (no. of lines executed/total > lines) *100. Since the script `x.py` is running multiple sql queries, it > usually won't be the case that the script would complete within few seconds > of its execution. That's a bit tricky. More useful would probably be to explicitly pepper your code with calls to some "still active" function, but it's going to be nearly impossible to get any sort of viable percent-done based on lines of code. There might be one primary loop that takes 80% of the execution time or more. You mention SQL queries. Can you wrap up the query handler in something that effectively treats _those_ as your fundamental divisions of "job-done-ness"? I'm not sure how (in either case, actually) you'd automatically figure out how many there are to do (either lines or queries), so you may still have to have something externally count them up - which would still not work if there's a loop, though with queries it's less sane to have a loop executing them than lines of code. ChrisA