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 'Bar' on <module '__main__' from 'miniconda3/envs/3.12.0/bin/viztracer'> #422

Closed
Honesty-of-the-Cavernous-Tissue opened this issue Apr 6, 2024 · 0 comments · Fixed by #423

Comments

@Honesty-of-the-Cavernous-Tissue

python: 3.12.0
viztracer: 0.16.2
os: macOS

here's my test script

from multiprocessing import get_context

class Bar:
    def __init__(self):
        self.total = 0
        ...

    def __add__(self, other):
        counter = Bar()
        for attr, val in counter.__dict__.items():
            if isinstance(val, int):
                counter[attr] += self[attr] + other[attr]
        return counter

    def __getitem__(self, item):
        return self.__getattribute__(item)

    def __setitem__(self, key, value):
        self.__setattr__(key, value)


def foo(frag):
    counter = Bar()
    counter.total += frag
    return counter


if __name__ == '__main__':
    frags = [*range(8)]
    with get_context('spawn').Pool(8) as pool:
        _ = sum(pool.imap_unordered(foo, frags), start=Bar())

after ran viztracer test.py
got this error
image

@Honesty-of-the-Cavernous-Tissue Honesty-of-the-Cavernous-Tissue changed the title AttributeError: Can't get attribute 'Bar' on <module '__main__' from '/Users/zyq/miniconda3/envs/3.12.0/bin/viztracer'> AttributeError: Can't get attribute on <module '__main__' from '/Users/zyq/miniconda3/envs/3.12.0/bin/viztracer'> Apr 6, 2024
@Honesty-of-the-Cavernous-Tissue Honesty-of-the-Cavernous-Tissue changed the title AttributeError: Can't get attribute on <module '__main__' from '/Users/zyq/miniconda3/envs/3.12.0/bin/viztracer'> AttributeError: Can't get attribute on <module '__main__' from 'miniconda3/envs/3.12.0/bin/viztracer'> Apr 6, 2024
@Honesty-of-the-Cavernous-Tissue Honesty-of-the-Cavernous-Tissue changed the title AttributeError: Can't get attribute on <module '__main__' from 'miniconda3/envs/3.12.0/bin/viztracer'> AttributeError: Can't get attribute on <module '__main__' from 'miniconda3/envs/3.12.0/bin/viztracer'> Apr 6, 2024
@Honesty-of-the-Cavernous-Tissue Honesty-of-the-Cavernous-Tissue changed the title AttributeError: Can't get attribute on <module '__main__' from 'miniconda3/envs/3.12.0/bin/viztracer'> AttributeError: Can't get attribute 'Bar' on <module '__main__' from 'miniconda3/envs/3.12.0/bin/viztracer'> Apr 6, 2024
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

Successfully merging a pull request may close this issue.

1 participant