line_profiler: what am I doing wrong?

Ethan Furman ethan at stoneleaf.us
Tue Feb 10 19:11:35 EST 2015


On 02/10/2015 04:06 PM, Neal Becker wrote:
> I inserted 
> @profile
> def run(...)
> 
> into a module-level global function called 'run'.  Something is very wrong here.
> 1. profile results were written before anything even ran
> 2. profile is not defined?
> 
>  kernprof -l ./test_unframed.py --lots --of --args ...
> 
> Wrote profile results to test_unframed.py.lprof
> Traceback (most recent call last):
>   File "/home/nbecker/.local/bin/kernprof", line 9, in <module>
>     load_entry_point('line-profiler==1.0', 'console_scripts', 'kernprof')()
>   File "/home/nbecker/.local/lib/python2.7/site-packages/kernprof.py", line 221, 
> in main
>     execfile(script_file, ns, ns)
>   File "./test_unframed.py", line 721, in <module>
>     @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~

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20150210/2014f5c0/attachment.sig>


More information about the Python-list mailing list