Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: Can't get attribute 'xx' on <module '__main__' from 'path/to/kernprof'> #189

Open
SysuJayce opened this issue Nov 25, 2022 · 3 comments

Comments

@SysuJayce
Copy link

I want to profile method in class with kernprof, but it seems that pickle is not supported. Any help is appreciated.

kernprof version: 4.0.1

Below is the code to reproduce the issue.

import pickle

class Data:
  pass

class Test:
  @profile
  def a(self):
    data = Data()
    pickle.dump(data, open("tmp.pkl", "wb"))

Test().a()

If we save the code into test.py and call kernprof -lv test.py, the error is:

_pickle.PicklingError: Can't pickle <class '__main__.Data'>: attribute lookup Data on __main__ failed

It seems that neither pickle.dump() nor pickle.load() is supporrted by line_profile currently.

@Erotemic
Copy link
Member

Does this work with the older 3.x branch?

@Mogost
Copy link
Member

Mogost commented Dec 9, 2022

Probably related to #191 (actually duplicates #183)

@kinghuang
Copy link

I'm having the same problem where using line_profiler appears to interfere with pickling objects. Not sure how to get around this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants