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

TypeError: cannot create weak reference to 'Lock' object #331

henry232323 opened this Issue Sep 26, 2017 · 1 comment


None yet
2 participants

henry232323 commented Sep 26, 2017

trio.Lock objects cannot be WeakReferenced! Is there a way we could get this fixed?


This comment has been minimized.


njsmith commented Sep 26, 2017

Huh, well, that's bizarre, and certainly not intentional. I suspect this is because they use __slots__ (via attr.s(slots=True, ...)), and probably affects a bunch of classes.

Ah-hah, yep: python-attrs/attrs#174

The simplest solution would be to go remove slots=True everywhere, since it's kind of a vague premature optimization in the first place...

njsmith added a commit to njsmith/trio that referenced this issue Sep 30, 2017

njsmith added a commit to njsmith/trio that referenced this issue Sep 30, 2017

Stop using slots=True in public classes to fix weakref issues
Hopefully we can switch back to using slots=True at some point because
the memory savings are nice, but currently it breaks
weakrefs (python-triogh-331), and currently the supposed workaround breaks on

  python-attrs/attrs#174 (comment)

(See also python-triogh-337 for an abortive attempt to apply that workaround.)

Fixes python-triogh-331

@njsmith njsmith closed this in #339 Oct 1, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment