Message292112
Thanks, Nick. Your analysis is very helpful.
After some testing, I found the problem here is because when we using `sys.setprofile` in the helper function, we didn't simulate the call (from where profiler create to helper function), that cause profile's frame link breakup, so if we want to return to outside of helper function, it will report a bad return.
A straightforward method is the latter method you propose, to make a profiler-aware function manually insert the frame into profiler's frame stack:
def _adjust_frame(self):
frame = sys._getframe(1) # Get helper function frame
self.dispatch['call'](self, frame, 0)
And adjust *before* install profiler:
def profile_helper(pr):
pr._adjust_frame()
sys.setprofile(pr.dispatcher)
Then we can get the correct thing we need. |
|
Date |
User |
Action |
Args |
2017-04-22 09:20:28 | louielu | set | recipients:
+ louielu, ncoghlan |
2017-04-22 09:20:28 | louielu | set | messageid: <1492852828.38.0.250547289324.issue30113@psf.upfronthosting.co.za> |
2017-04-22 09:20:28 | louielu | link | issue30113 messages |
2017-04-22 09:20:28 | louielu | create | |
|