Closed Theelx closed 1 year ago
Merging #191 (d7f766a) into main (83e4332) will not change coverage. The diff coverage is
n/a
.
Thank you @Theelx for taking time to fix this. Let me know when this PR is ready, and I'll merge.
It would be nice if we could add a test for this though. I don't quite understand what is difficult to reproduce here.
@Erotemic This PR is ready. The parts that are difficult to reproduce are that I don't actually know how this happened, because I don't fully understand the internals of method objects, and that when one uses the profile function as opposed to the profile decorator, this problem doesn't appear (even though it should be the same code path for both).
Can confirm that this PR fixes #183
Fixes #183, as evidenced by https://github.com/Theelx/sciris/actions/runs/3616146614. This has a negligible impact on performance because add_function is only called once per function, and try/excepts are zero-cost in CPython 3.11 anyway, iirc.
I would add a test for this, but it seems to be inconsistent as to how to get this error to appear. Sometimes the error showed up on GitHub Actions, but not locally, so I have no way to confirm precisely what code caused this.