Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #85492 > unrolled thread

Re: line_profiler: what am I doing wrong?

Started byNeal Becker <ndbecker2@gmail.com>
First post2015-02-10 19:18 -0500
Last post2015-02-10 19:18 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: line_profiler: what am I doing wrong? Neal Becker <ndbecker2@gmail.com> - 2015-02-10 19:18 -0500

#85492 — Re: line_profiler: what am I doing wrong?

FromNeal Becker <ndbecker2@gmail.com>
Date2015-02-10 19:18 -0500
SubjectRe: line_profiler: what am I doing wrong?
Message-ID<mailman.18638.1423613950.18130.python-list@python.org>
Ethan Furman wrote:

> 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~

I believe you are suggesting the apparent out-of-order is due to try/finally, 
but kernprof is supposed to inject 'profile' into the global namespace, so 
@profile should be defined - I don't know why it isn't working.

-- 
-- Those who don't understand recursion are doomed to repeat it

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web