[Twisted-Python] How to call super() using attrs?

Felipe Dau dau at riseup.net
Tue Jun 20 03:54:53 MDT 2017


I am trying to use attrs in a class that inherits from Thread but I
have not found a way to call super():

    >>> @attr.s
    ... class T(Thread, object):
    ...     def __attr_post_init__(self):
    ...             super(T, self).__init__()
    ... 
    >>> t = T()
    >>> t.start()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python2.7/threading.py", line 737, in start
        raise RuntimeError("thread.__init__() not called")
    RuntimeError: thread.__init__() not called

I even tried to call that in __attr_post_init__(), but maybe super()
should be called in a pre-init method?

Thanks,
-Felipe



More information about the Twisted-Python mailing list