Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'skip:" 60': 0.07; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'inserted': 0.09; 'message- id:@stoneleaf.us': 0.09; '~ethan~': 0.09; 'def': 0.12; 'wrote': 0.14; 'filename:fname piece:signature': 0.16; 'nameerror:': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'written,': 0.19; 'written': 0.21; 'header:User-Agent:1': 0.23; 'skip:l 30': 0.24; 'skip:" 30': 0.26; 'defined': 0.27; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "i'm": 0.30; "skip:' 10": 0.31; 'subject:what': 0.31; 'file': 0.32; '(most': 0.33; 'guess': 0.33; 'something': 0.35; 'subject:?': 0.36; 'wrong': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'anything': 0.39; 'recent': 0.39; 'skip:. 10': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'even': 0.60; 'profile': 0.61; 'received:173': 0.61; 'first': 0.61; 'name': 0.63; 'results': 0.69; 'subject:skip:l 10': 0.84 Date: Tue, 10 Feb 2015 16:11:35 -0800 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: line_profiler: what am I doing wrong? References: In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="8GHMgBAkOOQXhlRHK9wPnTj7LvJdiGpxf" 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: 62 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1423613509 news.xs4all.nl 2867 [2001:888:2000:d::a6]:54091 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85490 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --8GHMgBAkOOQXhlRHK9wPnTj7LvJdiGpxf Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 02/10/2015 04:06 PM, Neal Becker wrote: > I inserted=20 > @profile > def run(...) >=20 > into a module-level global function called 'run'. Something is very wr= ong here. > 1. profile results were written before anything even ran > 2. profile is not defined? >=20 > kernprof -l ./test_unframed.py --lots --of --args ... >=20 > Wrote profile results to test_unframed.py.lprof > Traceback (most recent call last): > File "/home/nbecker/.local/bin/kernprof", line 9, in > load_entry_point('line-profiler=3D=3D1.0', 'console_scripts', 'kern= prof')() > File "/home/nbecker/.local/lib/python2.7/site-packages/kernprof.py", = line 221,=20 > in main > execfile(script_file, ns, ns) > File "./test_unframed.py", line 721, in > @profile > NameError: name 'profile' is not defined I'm going to guess that writing the profile results is in a try/finally -= - so first you see the results being written, then the exception that triggered. -- ~Ethan~ --8GHMgBAkOOQXhlRHK9wPnTj7LvJdiGpxf Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBAgAGBQJU2p46AAoJENZ7D1rrH75ND5YP/2qENrf0/UHpCMemniu6ijKT 2gtVLAwkvnubMngVvFxuLaZdKHlF8YyFGSPsi8d5GNdgZBXSWMaecPtD7jNh96mD RrBrVh/JCdAaimFFc+2fKuL2rdQKm1TAPSfzsdy1zlzOBRLPnOk/RRYvRy4lpzY3 TRjH9IsouLM7UvQJ7zQrO2FQVi+h5wIi9ks0fycMiCwPn2eaxDTbGyYFFnjPf4e3 nm3UufDptQ4deDKH1CG3Zw1UiI6DKX46eorndg6YfjlZrR26Ne/WdnrdK8uUxyAK HrTAsQldVbIjRxIRYt9XdnjZZyKkAt8ice+S77q/+UMwJrBX9XLf2w2LMlrG4o17 82VMZw9rzqPELXqsU1gICyi8KQFsFov33PxJp6tcedsuoJhHNX32mfDu0FDYVQqa x0deLC0Z7UdapDxP4mNHmnXJ+DUutlnum6786YaAuZrXmjMsc8n7OQvC/0dzhmvV BgIP0lViJSrfbK33e4oJ6C/yfsaKARwGJdBbAT+vcSnZa4qIN/0EeHNMALc884Us 9cuw2CQVlc3Ad2vq4jBl6m8ryCsNQCoFObNlRelVHsp98aLAy6xeR4uUYYgYD/M3 Y0HgdVDUHqONnaNrFOXmjpwjuxACWU4gOjIomGHjlTxK0MSAhB3OetLqIzWELI28 CNNy2mTlLpOMfOyqicNe =JwIl -----END PGP SIGNATURE----- --8GHMgBAkOOQXhlRHK9wPnTj7LvJdiGpxf--